早教吧 育儿知识 作业答案 考试题库 百科 知识分享

python改错,错误functionobjectisnotsubscriptable代码如下defchangematrix(weimatrix,sample):newmatrix3=[[[0foriinrange(7)]forjinrange(7)]forkinrange(7)]newmatrix3=weightmatrixchangedsample=[[0forminrange(7)]fornin

题目详情
python改错,错误 function object is not subscriptable
代码如下
def change_matrix(wei_matrix,sample):
new_matrix3 = [[[0 for i in range(7)] for j in range(7)]for k in range(7)]
new_matrix3=weight_matrix
changed_sample=[[0 for m in range(7)] for n in range(7)]
for u in range(7):
for v in range(7):
for w in range(7):
plus1=(new_matrix3[u][v][w])*(sample[u][w]) #此处错误*(new_matrix3[u][v][w])
changed_sample[u][v]+=plus1
if changed_sample[u][v]>=0:
changed_sample[u][v]=1
elif changed_sample[u][v]
▼优质解答
答案和解析
你传进去的参数wei_matrix是3阶矩阵么?不是的话就有问题