无法识别pytorch中的就地操作

时间:2019-01-23 14:27:24

标签: python deep-learning pytorch

我收到此错误:

one of the variables needed for gradient computation has been modified by an inplace operation

这是我的摘录:

self.scorer = nn.Linear(hidden_dim, 1)
mat = []
for i in range(seq2_len):
    temp = []
    for j in range(seq1_len):
        seq2_state = sequence2_[:,i,:]
        seq1_state = sequence1_[:,j,:]
        diff = self.scorer(T.abs(seq1_state - seq2_state)).squeeze()
        temp.append(diff)
    temp = T.stack(temp)
    mat.append(temp)

mat = T.stack(mat)
mat = T.transpose(T.transpose(mat, 2, 0), 2, 1)

你能帮我吗?

0 个答案:

没有答案