Created
September 6, 2021 06:08
-
-
Save andreaschandra/70fb0308e7a3946c89fb4cdc7cb60150 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# import modules | |
import torch.nn as nn | |
import torch.optim as optim | |
# define optimizer | |
# using previous model that we have built | |
# using Adam optimizer and learning rate = 0.001 | |
optimizer = optim.Adam(model.parameters(), lr=1e-3) | |
print(optimizer) | |
# define loss function | |
# if the task is regression probem we can use Mean Squared Error | |
loss_fn = nn.MSELoss() | |
# if the task is binary classification problem, we can use BCELoss | |
loss_fn = nn.BCELoss() | |
# if the task is multiclass classification problem, we can use CrossEntropy | |
loss_fn = nn.CrossEntropyLoss() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment