Created
November 30, 2017 16:16
-
-
Save jojonki/f30527587712662aeda1c11f06880748 to your computer and use it in GitHub Desktop.
Convert to Variable in PyTorch
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
| from torch.autograd import Variable | |
| def to_var(x): | |
| if torch.cuda.is_available(): | |
| x = x.cuda() | |
| return Variable(x) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment