Optimizers
It's time to explore the different optimizers that you can use for training your model.
A custom function called train_model(optimizer, net, num_epochs) has been defined for you. It takes the optimizer, the model, and the number of epochs as inputs, runs the training loops, and prints the training loss at the end.
Let's use train_model() to run a few short trainings with different optimizers and compare the results!
Bu egzersiz
Intermediate Deep Learning with PyTorch
kursunun bir parçasıdırUygulamalı interaktif egzersiz
Bu örnek kodu tamamlayarak bu egzersizi bitirin.
import torch.optim as optim
net = Net()
# Define the SGD optimizer
optimizer = optim.____(net.parameters(), lr=0.001)
train_model(
optimizer=optimizer,
net=net,
num_epochs=10,
)