我在运行代码时遇到此错误,但我不明白为什么。我试着打印变量' j'但它确实有一个非空值。
这里是追溯:
[array([ 0., 10.]), array([ 0. , 0.59]), array([ 0. , 1.35]), array([ 0., 1.])]
Traceback (most recent call last):
File "model.py", line 300, in <module>
main()
File "model.py", line 293, in main
training(model, data)
File "model.py", line 272, in training
[lambdas, clus, conn] = model.learn(j,env)
TypeError: 'NoneType' object is not iterable
从功能训练(模型,数据):
for j in trainingblock:
print j
[res,prob,outunits,outacts,act,dist] = model.stimulate(j, env)
if res == True:
nitemscorrect += 1
accuracy = 1
[lambdas, clus, conn] = model.learn(j,env)
else:
accuracy = 0
答案 0 :(得分:3)
此处发生错误:
[lambdas, clus, conn] = model.learn(j,env)
Python试图将learn
返回的值解包为三个左手变量。但是,函数返回None
,因此python无法为这些变量赋值并引发异常。
x, y, z = [1, 2, 3] # works
x, y, z = None # error