Pata_Naheen:

output = rnn(item) target = y[i] #print(target) #target = target.squeeze_() #print(“input shape:”,output.shape, “output shape:”, target.shape) loss = loss_func(output, target.argmax(dim=1))


So, given that the shape of output is (2) and the target is (1,2), then I think the following changes may solve the issue:
        output = rnn(item)
        target = y[i]
        # reshape the output:
        output = output.reshape(-1, 2)
        # get elements in the second column of target
        target = target[:,1]
        
        # now compute the loss
        loss = loss_func(output, target.argmax(dim=1))