有人可以告诉我为什么会收到此错误?
output_shape = tf.pack([batch_size, 24, 24, 5])
result = tf.nn.deconv2d(..., filter, output_shape=output_shape,
strides=[1, 2, 2, 1], padding='SAME')
这是我的代码:
result[i][j+1]=X[i][j]
IndexError: list assignment index out of range
答案 0 :(得分:1)
您无法在result
处为len(X[0])+1
编制索引,因为其尺寸为len(X)
len(X[0])
。此外,您的matrixTranpose
函数似乎没有采用X
的转置。大概你的意思是:
def matrixTranspose(X):
result=[[0 for k in range (len(X))] for l in range (len(X[0]))]
for i in range(len(X)):
for j in range (len(X[0])):
result[j][i]=X[i][j]
return result