数学基礎第四章のまとめです。
公式のみを扱います。
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import math | |
def avg_entropy(num_arr): | |
num_arr = list(map(lambda x: x * math.log2(x), num_arr)) | |
return -sum(num_arr) | |
if __name__=='__main__': | |
input_num = [0.05, 0.25, 0.70] | |
output = avg_entropy(input_num) | |
print('output :', output) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import cv2 | |
ESC_KEY = 27 | |
cap = cv2.VideoCapture(0) | |
while True: | |
ret, frame = cap.read() | |
# |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from io import BytesIO | |
from PIL import Image | |
import matplotlib.pyplot as plt | |
import numpy as np | |
import cv2 | |
cap = cv2.VideoCapture(0) | |
ret, frame = cap.read() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from tensorflow.keras.utils import to_categorical | |
def preprocessing(data, ch=3, label=False): | |
if label: | |
return to_categorical(data) | |
data = data / 255.0 | |
w, h = data[0:3] | |
data = data.reshape((-1, w, h, ch)) | |
return data |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import requests | |
from io import BytesIO | |
from PIL import Image | |
import numpy as np | |
def url_to_image(url): | |
""" | |
url -> np.array (RGB) | |
""" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from sklearn.datasets import load_digits | |
import matplotlib.pyplot as plt | |
data = load_digits() | |
for num, image, label in zip(range(10), data.images[:10], data.target[:10]): | |
plt.subplot(2, 5, num+1) | |
plt.imshow(image) | |
plt.title(label) |
NewerOlder