Skip to content

Instantly share code, notes, and snippets.

View lockdef's full-sized avatar
👤
happy

lockdef lockdef

👤
happy
View GitHub Profile
@lockdef
lockdef / AvgEntropy.py
Created July 12, 2019 01:51
平均エントロピーの関数
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)
@lockdef
lockdef / ReadVideo.py
Created May 31, 2019 05:50
OpenCVで動画を読み込むプログラムの雛形
import cv2
ESC_KEY = 27
cap = cv2.VideoCapture(0)
while True:
ret, frame = cap.read()
#
@lockdef
lockdef / RealTimeGraph.py
Last active May 21, 2019 13:24
リアルタイムでグラフを描写する
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()
@lockdef
lockdef / Preprocessing.py
Created May 14, 2019 04:23
データセットの前処理
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
@lockdef
lockdef / url_to_image.py
Last active May 22, 2019 00:38
画像のURLを受け取りNumpyのArrayに変換する
import requests
from io import BytesIO
from PIL import Image
import numpy as np
def url_to_image(url):
"""
url -> np.array (RGB)
"""
@lockdef
lockdef / PrimeNumbetChecker.py
Created April 18, 2019 14:08
素数判定ver2
n=int(input());print('YNEOS'[n-len([_ for _ in range(1,n+1) if n%_])==2::2])
n=int(input());print(('YES' if len([_ for _ in range(1,n+1) if n%_==0])==2 else 'NO'))
@lockdef
lockdef / MNISTPlot.py
Created April 10, 2019 02:24
MNISTをプロットする
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)

はじめに

数学基礎第四章のまとめです。
公式のみを扱います。

指数法則

$a^ba^c=a^{b+c}$

$(a^b)^c=a^{bc}$

$(ab)^c=a^cb^c$

はじめに

Python3を用いたグラフ描写プログラムを書いていきます。

環境

Python 3.6.6
matplotlib
numpy