Skip to content

Instantly share code, notes, and snippets.

@gagejustins gagejustins/optimizer.py
Last active Apr 16, 2018

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
You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.