Passing a 1d tensor to conv1d

Hello! I have a 1D tensor, with 500 entries and I want to pass it to a conv1d. After I put it into a mini batch of size 10 and I call x.size() I get this output: torch.Size([10, 500]). However the conv1d gives an error, requiring a 3D tensor, so I tried to add one more dimension, corresponding to the number of input channels (which is 1) so I did this: x = x[:,None,:] and the output of x.size() is this: torch.Size([10, 1, 500]) which is what I want. However, when I pass it again to the conv1d I get this error: TypeError: argument 0 is not a Variable. I updated my pytorch but I get the same error. What should I do? Thank you!

Thank you for your reply. However, if I do that I get this error: RuntimeError: Variable data has to be a tensor, but got Variable The part of the code I am looking at looks like this:

from torch.autograd import Variable
c = nn.Conv1d(1,3,4,1)
x = x[:,None,:]
x = Variable(x)
c(x)

I apologize, that was a stupid mistake (I called x = Variable(x)) twice. However, I am still getting this error: RuntimeError: Expected object of type torch.DoubleTensor but found type torch.FloatTensor for argument #2 'weight' (Sorry I am just getting started with NN and pytorch)

can you make the model and all the tensors to float data type by calling .float() on them?