2019-04-16
阅读量:
699
神经网络的目标
目标是为这个神经元找到最佳权重集,从而产生正确的结果。通过使用几个不同的训练样例训练神经元来做到这一点。在每一步计算神经元输出中的误差,然后反向传播梯度。计算神经元输出的步骤称为前向传播,而梯度计算称为反向传播。
以下是实施:
# Python program to implement a
# single neuron neural network
# import all necessery libraries
from numpy import exp, array, random, dot, tanh
# Class to create a neural
# network with single neuron
class NeuralNetwork():
def __init__(self):
# Using seed to make sure it'll
# generate same weights in every run
random.seed(1)
# 3x1 Weight matrix
self.weight_matrix = 2 * random.random((3, 1)) - 1
# tanh as activation fucntion
def tanh(self, x):
return tanh(x)






评论(0)


暂无数据
推荐帖子
0条评论
0条评论
0条评论