Mysterious nn.Parameter behavior
<SCODE>import torch
from torch import nn

class Model(nn.Module):
    def __init__(self, deg):
	super(Model, self).__init__()
	self.deg = deg + 1

	self.theta = nn.Parameter(torch.ones(self.deg), 1)

     def forward(self, xs):
	phi = torch.cat([xs**i for i in range(self.deg)], 1)
	res = phi @ self.theta 
            # phi.mv(self.theta) # if not python 3.5 or later
	print(res)
	return res

model = Model(2)
#print(list(model.parameters()))
x = FloatTensor([1, 2,3, 4]).unfold(0,1,1)

print(model(x))
<ECODE> Here is the error that I get: <SCODE>Traceback (most recent call last):
  File "01-polynomial-fitting.py", line 40, in <module>
    print(model(x))
  File "/home/arseni/.anaconda/envs/mlt/lib/python3.6/site-packages/torch/nn/modules/module.py", line 206, in __call__
    result = self.forward(*input, **kwargs)
  File "01-polynomial-fitting.py", line 29, in forward
    res = phi @ self.theta
  File "/home/arseni/.anaconda/envs/mlt/lib/python3.6/site-packages/torch/tensor.py", line 357, in __matmul__
    return self.mv(other)
TypeError: mv received an invalid combination of arguments - got (Parameter), but expected (torch.FloatTensor vec)
<ECODE> <SCODE>Traceback (most recent call last):
  File "01-polynomial-fitting.py", line 40, in <module>
    print(model(x))
  File "/home/arseni/.anaconda/envs/mlt/lib/python3.6/site-packages/torch/nn/modules/module.py", line 215, in __call__
    var = var[0]
TypeError: 'float' object is not subscriptable
<ECODE> <SCODE>Traceback (most recent call last):
  File "01-polynomial-fitting.py", line 41, in <module>
    print(model(x))
  File "/home/arseni/.anaconda/envs/mlt/lib/python3.6/site-packages/torch/nn/modules/module.py", line 206, in __call__
    result = self.forward(*input, **kwargs)
  File "01-polynomial-fitting.py", line 29, in forward
    res = (self.theta @ phi.t())
  File "/home/arseni/.anaconda/envs/mlt/lib/python3.6/site-packages/torch/autograd/variable.py", line 770, in __matmul__
    return self.unsqueeze(0).mm(other).squeeze(0)
  File "/home/arseni/.anaconda/envs/mlt/lib/python3.6/site-packages/torch/autograd/variable.py", line 523, in mm
    output = Variable(self.data.new(self.data.size(0), matrix.data.size(1)))
AttributeError: 'FloatTensor' object has no attribute 'data'
<ECODE> What am I doing wrong ?
username1
<SCODE>print(model(Variable(x)))
<ECODE>
fmassa
Thanks for your answer. Now its working.
username1