# 深度学习的一点点一点点知识

## 深度学习第一天

x W Y

x1 x2 Y
0 0 0
0 1 0
1 0 0
1 1 1

def AND(x1, x2):
w1, w2, theta = 0.5, 0.5, 0.7
tmp = x1*w1 + x2*w2
if tmp <= theta:
return 0
elif tmp > theta:
return 1


x1 x2 Y
0 0 1
0 1 1
1 0 1
1 1 0

x1 x2 Y
0 0 0
0 1 1
1 0 1
1 1 1

import  numpy as np
x = np.array([0,1])
w = np.array([0.5,0.5])
b = -0.7
print(np.sum(w*x))
print(np.sum(w*x)+b)
#0.5
#-0.19999999999999996


def AND(x1, x2):
w1, w2, theta = 0.5, 0.5, 0.7
tmp = x1*w1 + x2*w2
if tmp <= theta:
return 0
elif tmp > theta:
return 1
#0 0 0 1


import  numpy as np
def AND(x1,x2):
w = np.array([0.5,0.5])
x = np.array([x1,x2])
b = -0.7
tmp = np.sum(w*x)+b
if tmp <= 0:
return 0
elif tmp > 0:
return 1
#0 0 0 1


import numpy as np
def NAND(x1,x2):
w = np.array([-0.5,-0.5])#仅权重和偏置改变了
x = np.array([x1,x2])
b = 0.7
tmp = np.sum(w*x)+b
if tmp <=0:
return 0
elif tmp >0:
return 1

def OR(x1, x2):
x = np.array([x1, x2])
w = np.array([0.5, 0.5]) # 仅权重和偏置与AND不同！
b = -0.2
tmp = np.sum(w*x) + b
if tmp <= 0:
return 0
else:
return 1
# 1 1 1 0
# 0 1 1 1



def XOR(x1,x2):
s1 = NAND(x1,x2)
s2 = OR(x1,x2)
y = AND(s1,s2)
return y
# 0 1 1 0


## 先说这些，剩下的有缘再见

©️2019 CSDN 皮肤主题: 数字20 设计师: CSDN官方博客