Complete the code to perform a forward pass using the model.
outputs = model([1])The forward pass uses the input data to get predictions from the model.
Complete the code to calculate the loss between outputs and labels.
loss = criterion(outputs, [1])Loss compares the model's outputs to the true labels to measure error.
Fix the error in the code to perform backpropagation.
loss.[1]()step() on loss instead of optimizer.zero_grad() on loss.Calling backward() computes gradients for backpropagation.
Fill both blanks to reset gradients and update model parameters.
optimizer.[1]() optimizer.[2]()
backward() or forward() on optimizer.First, gradients are cleared with zero_grad(). Then, step() updates the model weights.
Fill all three blanks to complete a training step: forward pass, loss calculation, and backward pass.
outputs = model([1]) loss = criterion(outputs, [2]) loss.[3]()
The training step starts with inputs to get outputs, then calculates loss with labels, and finally calls backward() to compute gradients.