Can’t find the problem place.I cant find inplace problem operations. RuntimeError: one of the variables needed for gradient computation has been modified by an inplace operation: [torch.cuda.FloatTensor [1, 5]], which is output 0 of UnsqueezeBackward0, is at version 321; expected version 316 instead
here is the forward code:
def forward(self, x):
    if len(x.shape) == 3:

        x1 = x.view(1, self.channels, self.bars, self.input_dim) 

        x2 = self.norm(x1)

    else:

        x2 = self.norm(x)

    save = torch.zeros(x2.size()[0], self.act_size).to(device)

    out = torch.zeros(self.channels).to(device)

    for b in range(x2.size()[0]):

        y0 = x2[b][0].view(1, self.bars, self.input_dim)

        y1 = x2[b][1].view(1, self.bars, self.input_dim)

        y2 = x2[b][2].view(1, self.bars, self.input_dim)

        y3 = x2[b][3].view(1, self.bars, self.input_dim)

        y4 = x2[b][4].view(1, self.bars, self.input_dim)

        lstm_out_0, hid_0 = self.lstm_0(y0)

        lstm_out_1, hid_1 = self.lstm_1(y1)

        lstm_out_2, hid_2 = self.lstm_2(y2)

        lstm_out_3, hid_3 = self.lstm_3(y3)

        lstm_out_4, hid_4 = self.lstm_4(y4)

        out[0] = hid_0[0][-1]

        out[1] = hid_1[0][-1]

        out[2] = hid_2[0][-1]

        out[3] = hid_3[0][-1]

        out[4] = hid_4[0][-1]

        save[b] = self.dense(out)

    return save