-
-
Save amankharwal/90e5dbea343c492cbc44b650cf89b711 to your computer and use it in GitHub Desktop.
This file contains 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 matplotlib.pyplot as plt | |
with torch.no_grad(): # we don't need gradients in the testing phase | |
if torch.cuda.is_available(): | |
predicted = model(Variable(torch.from_numpy(x_train).cuda())).cpu().data.numpy() | |
else: | |
predicted = model(Variable(torch.from_numpy(x_train))).data.numpy() | |
print(predicted) | |
plt.clf() | |
plt.plot(x_train, y_train, 'go', label='True data', alpha=0.5) | |
plt.plot(x_train, predicted, '--', label='Predictions', alpha=0.5) | |
plt.legend(loc='best') | |
plt.show() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment