http://pytorch.org/docs/master/nn.html#torch.nn.CrossEntropyLoss 175
ignore_index should be specified when you construct the criterion function, ie,
criterion = nn.CrossEntropyLoss(ignore_index = -1)
And then you can use it elsewhere:
criterion(output, target)