Hello,
I was reading pytorch documentation on nn.NLLLoss module. I tried out the following example provided:



2D loss example (used, for example, with image inputs)
N, C = 5, 4
loss = nn.NLLLoss()
input is of size N x C x height x width
data = torch.randn(N, 16, 10, 10)
m = nn.Conv2d(16, C, (3, 3))
each element in target has to have 0 <= value < C
target = torch.tensor(N, 8, 8).random_(0, C)
output = loss(m(data), target)
output.backward()



but  I get this error instead.
ValueError: Expected input batch_size (5) to match target batch_size (3).
Thanks for in advance for the help and assistances!