You should be using F.cross_entropy_loss, not the nn.Module form (or you can write your second line as a = nn.CrossEntropyLoss()(output_y, y_labels)). Right now you’re just creating a module, not actually computing the loss.