Skip to content

Instantly share code, notes, and snippets.

@gagejustins
Last active July 28, 2021 09:16
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save gagejustins/049281b521fdf845585b441e16b17b73 to your computer and use it in GitHub Desktop.
Save gagejustins/049281b521fdf845585b441e16b17b73 to your computer and use it in GitHub Desktop.
#Import the optim module from the pytorch package
import torch.optim as optim
#Initialize an optimizer object
learning_rate = 0.001
optimizer = optim.Adam(net.parameters(), lr=learning_rate)
#Set the parameter gradients to 0 and take a step (as part of a training loop)
for epoch in num_epochs:
train(...)
optimizer.zero_grad()
optimizer.step()
#Import the support vector machine module from the sklearn framework
from sklearn import svm
#Label x and y variables from our dataset
x = ourData.features
y = ourData.labels
#Initialize our algorithm
classifier = svm.SVC()
#Fit model to our data
classifier.fit(x,y)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment