nn.NLLLoss expects the inputs to be log probabilities, while you are passing the probabilities into the criterion.
Also, your manual calculation seem to mix the target indices, as the first sample will have the class1 as its target and the second one class0.
Here is an example showing the same result:
loss = nn.NLLLoss()
a = torch.tensor(([0.88, 0.12], [0.51, 0.49]), dtype = torch.float)
target = torch.tensor([1, 0])
output = loss(torch.log(a), target)
print(output)
> tensor(1.3968)
print((-torch.log(a[0, 1]) - torch.log(a[1, 0])) / 2)
> tensor(1.3968)