ãã¼ãããä½ãDeep Learningãããã£ã¦ããã¡ãã¨Deep Learningã®åºç¤ãç解ãããã£ãã®ã§ãè³¼å ¥ããã
èªãã§ã³ã¼ããæ¸ããªãããããã°ã«ãè¨é²ãã¦ããã
2ç« ãã¼ã»ãããã³
1ç« ã¯Pythonèªä½ã¨ãnumpyã¨ãã®èª¬æãªã®ã§çãã
2ç« ããé²ããã
å 容ã¯ããã¼ã»ãããã³ã®èª¬æã¨ãããã使ã£ãè«çã²ã¼ãã®å®è£ ã
ãã¼ã»ãããã³ãã¯ã©ã¹ã§å®è£ ãã¦ãéã¿ãã³ã³ã¹ãã©ã¯ã¿ã®å¼æ°ã«ããã¨è¯ããããªæ°ãããã®ã§ããããªæãã§ãã£ã¦ã¿ãã
import numpy as np
ã¯ã©ã¹ã§ãã¼ã»ãããã³ãå®è£
class perceptron: def __init__(self, w1:float, w2:float, b:float) -> None: self.w = np.array([w1, w2]) self.b = b def __call__(self, x1:float, x2:float) -> float: x = np.array([x1, x2]) return 1.0 if (self.b + np.sum(self.w * x) > 0.0) else 0.0
ANDã²ã¼ãã®å®è£
éã¿ã¯é©å½ã
p_and = perceptron(0.5, 0.5, -0.7) print(p_and(0, 0)) print(p_and(0, 1)) print(p_and(1, 0)) print(p_and(1, 1))
0.0
0.0
0.0
1.0
NANDã²ã¼ãã®å®è£
éã¿ãå¤ããã
p_nand = perceptron(-0.5, -0.5, 0.7) print(p_nand(0,0)) print(p_nand(0,1)) print(p_nand(1,0)) print(p_nand(1,1))
1.0
1.0
1.0
0.0
ORã²ã¼ãã®å®è£
ãããéã¿ãå¤ããã ãã
p_or = perceptron(0.5, 0.5, -0.2) print(p_or(0,0)) print(p_or(0,1)) print(p_or(1,0)) print(p_or(1,1))
0.0
1.0
1.0
1.0
XORã²ã¼ãã®å®è£
3種é¡ã®ã²ã¼ããçµã¿åãããã
def p_xor(x1, x2): return p_and(p_or(x1, x2), p_nand(x1, x2)) print(p_xor(0,0)) print(p_xor(0,1)) print(p_xor(1,0)) print(p_xor(1,1))
0.0
1.0
1.0
0.0
以ä¸
ããããã©ãã©ãé²ãã¦ãç解ãã¦ããããã