Hello I am writing a small pytorch example with a simple NN. The program runs fine if I declare
dtype = torch.FloatTensor
#dtype = torch.cuda.FloatTensor # Uncomment this to run on GPU
The code currently runs great with the CPU option. However, as soon as I uncomment and switch to the GPU option, the code crashes when I try to run forward on a model
y_estimate = NN(x)				# Forward pass

With the following error :
File “./test.py”, line 44, in 
y_estimate = NN(x)				# Forward pass
File “/home/chieh/App/miniconda/lib/python2.7/site-packages/torch/nn/modules/module.py”, line 325, in call
result = self.forward(*input, **kwargs)
File “/home/chieh/App/miniconda/lib/python2.7/site-packages/torch/nn/modules/container.py”, line 67, in forward
input = module(input)
File “/home/chieh/App/miniconda/lib/python2.7/site-packages/torch/nn/modules/module.py”, line 325, in call
result = self.forward(*input, **kwargs)
File “/home/chieh/App/miniconda/lib/python2.7/site-packages/torch/nn/modules/linear.py”, line 55, in forward
return F.linear(input, self.weight, self.bias)
File “/home/chieh/App/miniconda/lib/python2.7/site-packages/torch/nn/functional.py”, line 835, in linear
return torch.addmm(bias, input, weight.t())
RuntimeError: Expected object of type Variable[torch.FloatTensor] but found type Variable[torch.cuda.FloatTensor] for argument #1 ‘mat1’
I guess I just need to change the input type for the model, but i'm not sure how to do it. Any help would be great. Here is the full code


  
      docs.google.com
  
  
    

Train Basic Neural Net pytorch 460

#!/usr/bin/env python   #This example show how to use pytorch to solve a small neural net #	input layer 3 dimension #	hidden layer 4 dimension #	output layer 1 dimension, sigmoid activation  import torch from torch.autograd import Variable import...

  
  
    
    
  
  


Thank you.