Pytorch runtimeError "matrices expected, got 1D, 2D tensors at"
I begin to practice Pytorch ，try to use torch.mm() method。

Below is my code

import torch 
import numpy as np
from torch.autograd import Variable
num_x = np.array([[1.0, 2.0]
                  ,[3.0,4.0]])

tensor_x = torch.from_numpy(num_x)
x = Variable(tensor_x,requires_grad = True)
s = Variable(torch.DoubleTensor([0.01,0.02]),requires_grad = True)
print(s)
s = s.mm(x)
print(s)


Unfortunately,there is a runtime error 

*RuntimeError                              Traceback (most recent call last)
&lt;ipython-input-58-e8a58ffb2545&gt; in &lt;module&gt;()
      9 s = Variable(torch.DoubleTensor([0.01,0.02]),requires_grad = True)
     10 print(s)
---&gt; 11 s = s.mm(x)
     12 print(s)
RuntimeError: matrices expected, got 1D, 2D tensors at /pytorch/aten/src/TH/generic/THTensorMath.cpp:131*


How can I fix this problem。
your reply is appreciated 

try reshape you need to change shape of s to (1,2) to make possible matrix multiplication operation with (2,2) tensor

&gt;&gt;&gt; s.reshape(1,2).mm(x)
tensor([[0.0700, 0.1000]], dtype=torch.float64, grad_fn=&lt;MmBackward&gt;)


Or give right shape when initializing s

&gt;&gt;&gt; s = Variable(torch.DoubleTensor([[0.01,0.02]]),requires_grad = True)
&gt;&gt;&gt; s.mm(x)
tensor([[0.0700, 0.1000]], dtype=torch.float64, grad_fn=&lt;MmBackward&gt;)

