it should be set up like in examples in pytorch docs i.e.
input is of size nBatch x nClasses = 3 x 5
input = autograd.Variable(torch.randn(3, 5))
each element in target has to have 0 <= value < nclasses
target = autograd.Variable(torch.LongTensor([1, 0, 4]))
output = F.nll_loss(F.log_softmax(input), target)
output.backward()
Can you provide link to code you have now?
something like this:
def forward(self, x):
x = x.view (-1, 784)
x = F.tanh(self.hidden(x))
x = F.dropout(x,0.2)
x = F.sigmoid(self.hidden2(x))
x = F.dropout(x,0.2)
x = F.softmax(self.hidden3(x))
x = self.out(x)
Return F.log_softmax(x)
has to be after output of last linear layer