Hi,
I have a similar problem as above and I assigned output and hidden separately, but I still get the same error of the log_softmax. I’m using CrossEntropy as well.
class RNN(nn.Module):
def __init__(self, num_classes, input_size, hidden_size, num_layers,output_size):
    super(RNN, self).__init__()

    self.num_classes = num_classes
    self.num_layers = num_layers
    self.input_size = input_size
    self.hidden_size = hidden_size
    self.out = torch.nn.Linear(hidden_size, input_size)

    self.rnn = nn.RNN(4, 5,2, batch_first=True)
    self.fc = nn.Linear(hidden_size, output_size)

def forward(self, x):
    # Initialize hidden and cell states
    # (num_layers * num_directions, batch, hidden_size) for batch_first=True
    batch_size = x.size(0)
    hidden = self.init_hidden(batch_size)
    out, hidden = self.rnn(x, hidden)
    
    out = out.contiguous().view(-1, self.hidden_size)
    out = self.fc(out)
    return out, hidden

def init_hidden(self, batch_size):
    hidden = torch.zeros(self.num_layers, batch_size, self.hidden_size)
    return hidden