Instantly share code, notes, and snippets.

Embed
What would you like to do?
#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