我正在尝试实现一个简单的神经网络.我想打印初始图案,重量,激活.然后我想要它打印学习过程(即它学习时经历的每个模式).我还是无法做到这一点 - 它返回了初始和最终模式(我将print p放在适当的位置),但没有别的.提示和提示赞赏 - 我是Python的新手!
#!/usr/bin/python
import random
p = [ [1, 1, 1, 1, 1],
[1, 1, 1, 1, 1],
[0, 0, 0, 0, 0],
[1, 1, 1, 1, 1],
[1, 1, 1, 1, 1] ] # pattern I want the net to learn
n = 5
alpha = 0.01
activation = [] # unit activations
weights = [] # weights
output = [] # output
def initWeights(n): # set weights to zero, n is the number of …Run Code Online (Sandbox Code Playgroud) python ×1