Okay. For that to work then, your input to nll_loss needs to be of size N * C, where C = 5. In particular, input[n][0], input[n][1], input[n][2] should equal 0 for all n, and input[n][3], input[n][4] should (probably) be non-zero.