Thanks for your reply. I tried using permute in the model, but it showed the error

there are no graph nodes that require computing gradients.

The network I was using is
class Net(torch.nn.Module):
    def __init__(self):       
        super(Net, self).__init__()
        self.linear = [[torch.nn.Linear(100, 2) for i in range(5)] for j in range(3)]
    
    def forward(self, x):   
        N = len(x)
        y = torch.Tensor([[np.zeros((N,2)) for i in range(5)] for j in range(3)])
        for i in range(3):
            for j in range(5):
                y[i][j]=torch.nn.functional.log_softmax(nnFunc.relu(self.linear[i][j](x))).data
                     
        return Variable(y.permute(2,3,0,1))

I have to put Variable() wrapper there, otherwise it would show the error

‘float’ object has no attribute ‘getitem’