In numpy I can do a simple matrix multiplication like this:
a = numpy.arange(2*3).reshape(3,2)
b = numpy.arange(2).reshape(2,1)
print(a)
print(b)
print(a.dot(b))
However, when I am trying this with PyTorch Tensors, this does not work:
a = torch.Tensor([[1, 2, 3], [1, 2, 3]]).view(-1, 2)
b = torch.Tensor([[2, 1]]).view(2, -1)
print(a)
print(a.size())
print(b)
print(b.size())
print(torch.dot(a, b))
This code throws the following error: RuntimeError: inconsistent tensor size at /Users/soumith/code/builder/wheel/pytorch-src/torch/lib/TH/generic/THTensorMath.c:503
Any ideas how a simple dot product can be conducted in PyTorch?
Bug report : RuntimeError: /opt/conda/conda-bld/pytorch_1532581333611/work/torch/csrc/autograd/variable.h:127: Variable: Assertion is_variable() || !defined() failed: Tensor that was converted to Variable was not actually a Variable
I guess at::mm need Variable input , so which function should use to do multiplication?at::mm or something else?