初步的神经网络入门分为三篇
1:神经网络简析
这一篇主要是讲解一下关于用BP神经网络解决异或问题
对于我们的输入
[0,0],[0,1],[1,0],[1,1]
对于我们的输出
0或1
这里我们需要借用上一篇文章的一张图片
构建双层神经网络
#导入numpy
import numpy as np
#先定义训练数据
train_X = np.array([[0,0],[0,1],[1,0],[1,1]])
train_Y = np.array([0,1,1,0])
#线性连接层
class LinearLayer:
def __init__(self, input_D, output_D):
self._W = np.random.normal(0, 0.1, (input_D, output_D))#权值
self._b = np.random.normal(0, 0.1, (1,output_D))#偏置
self._grad_W = np.zeros((input_D,output_D))