Solved by fmassa in post #2 
              
              
                Instead of having a number, you should instead have a one-element vector encapsulated in a Variable. 
Note that we don’t have yet broadcasting implemented in pytorch, but it will be implemented soon, so for the moment you need to expand the tensor by hand. 
x = Variable(torch.from_numpy(np.ones(5)))…