Hi wsy!



 wsy:

X_grid = torch.from_numpy(np.linspace(0,1,50)).float().view(-1, d)
TypeError: float() argument must be a string or a number, not ‘builtin_function_or_method’


This works for me with pytorch version 0.3.0.
import torch
import numpy as np

torch.__version__

d = 10
X_grid = torch.from_numpy(np.linspace(0,1,50)).float().view(-1, d)
X_grid

And the output:
>>> import torch
>>> import numpy as np
>>>
>>> torch.__version__
'0.3.0b0+591e73e'
>>>
>>> d = 10
>>> X_grid = torch.from_numpy(np.linspace(0,1,50)).float().view(-1, d)
>>> X_grid

 0.0000  0.0204  0.0408  0.0612  0.0816  0.1020  0.1224  0.1429  0.1633  0.1837
 0.2041  0.2245  0.2449  0.2653  0.2857  0.3061  0.3265  0.3469  0.3673  0.3878
 0.4082  0.4286  0.4490  0.4694  0.4898  0.5102  0.5306  0.5510  0.5714  0.5918
 0.6122  0.6327  0.6531  0.6735  0.6939  0.7143  0.7347  0.7551  0.7755  0.7959
 0.8163  0.8367  0.8571  0.8776  0.8980  0.9184  0.9388  0.9592  0.9796  1.0000
[torch.FloatTensor of size 5x10]

The only thing I can think of is perhaps the d you are using isn’t
what you think it is.
Best.
K. Frank