I’ve never worked with Torch, only tf/th…, but the workflow seemed very pleasant to me so I decided try to learn. I know that pytorch is a very new project but it would be neat if one writes a “pytorch for dummies”.
For instance, the fallowing code results in error:
(class model above)
x = np.random.random(10)
ipt = torch.from_numpy(x)
probs = model(Variable(ipt))
TypeError: addmm_ received an invalid combination of arguments - got (int, int, torch.DoubleTensor, torch.FloatTensor), but expected one of:
* (torch.DoubleTensor mat1, torch.DoubleTensor mat2)
How is the proper data preparation in pytorch?
Thanks in advance and looking forward to use pytorch (the performance of the cart pole in openai gym was better than with other frameworks).
Obs: As I didn’t saw any other mechanic-ish question topic, nor a question flag, hope that is not off topic for the forum.
In this particular case, thanks for your feedback. We will improve our onboarding process, by making more newbie friendly tutorials.
In this case,
x = np.random.random(10) returns a numpy ndarray of
When you call
ipt = torch.from_numpy(x),
ipt is now a
However, your model is expecting a
torch.FloatTensor, so you simply do:
ipt = torch.from_numpy(x)
ipt = ipt.float()
I’m planning to release a series of video tutorials on PyTorch, something along the line of my torch-Video-Tutorials.
Would this meet your request?
Please, let me know of anything you think it should be included, so that I can better plan the structure of my lessons.
Great material! I was thinking on something like the video 2.2, a tutorial about how pytorch works.
Thanks for the reply, but after changing the tensor type to float I get the fallowing error:
RuntimeError: matrices expected, got 1D, 2D tensors at /Users/soumith/anaconda/conda-bld/pytorch0.1.6_1484755992574/work/torch/lib/TH/generic/THTensorMath.c:857
and the output for printing the
ipt variable is the fallowing:
[torch.FloatTensor of size 10]
@gabrieldlm pytorch does not support broadcasting yet. You are trying to send
ipt wich is a 1D vector of size 10 into a matrix-multiply, which expects a 2D Tensor.
You can do:
ipt = ipt.view(1, 10) if it fits your usecase.
Hey @gabrieldlm, I created a new repo: pytorch-Video-Tutorials.
Feel free to edit the wiki with your suggestions.
I’ll be reading the docs through this week, if I have any ideas I’ll add
Haha, I’m reading the docs and the source code too! It’s been a nice journey so far
This is the first place I ended up in when searching the error:
matrices expected, got 1D, 2D tensors at /py/conda-bld/pytorch_1490983232023/work/torch/lib/TH/generic/THTensorMath.c:1224
And even from smth’s comment and the documentation I’d say it’s not immediately obvious that the solution, at least in my case, is that the dimensionality of the input needed to be 3D rather than 2D. It does explain why
.view() makes frequent appearances in some of the tutorials.