I don’t know what 226 and 998 represent, but the error message points to an invalid index in nn.NLLLoss or nn.CrossEntropyLoss (which will call the former).
Make sure your model output is given as [batch_size, nb_classes] and the target as [batch_size] containing values in [0, nb_classes=1] for a multi-class classification use case.