I see. First, you have to initialize a loss “function” like criterion = nn.CrossEntropyLoss(). This actually create an object named criterion which is responsible for compute the loss later. nn.CrossEntropyLoss is itself not a direct function to compute the loss.