我是Python新手,所以我尝试使用以下代码调用ELM(position)函数来进行迭代:
def fitness(positon):
for i in range(len(position[0])):
acc[i] = ELM(position[i])
return acc
acc = fitness(position)
print(acc)
但是当我运行时,出现如下错误:
> > --------------------------------------------------------------------------- TypeError Traceback (most recent call last)
> > <ipython-input-32-b5817c120096> in <module> 3 acc[i] = ELM(position[i])
4 return acc
5 acc = fitness(position)
6 print(acc)
2 frames
> > <ipython-input-31-f7fd3cdc85c5> in matriks_kali(xtrain, transpose)
5
6 def matriks_kali(xtrain, transpose):
7 kaliHinittrain = np.zeros((len(xtrain), len(transpose[0])))
8 for i in range(len(xtrain)):
9 for j in range(len(transpose[0])):
TypeError: object of type 'numpy.float64' has no len()
1条答案
按热度按时间zkure5ic1#
position
可能是您尝试迭代的对象列表。请尝试删除position[0]
,然后查找len(position)