Module torch has no attribute float

import torch
import numpy as np

a = np.zeros((3,3))
b = torch.from_numpy(a).type(torch.float)

AttributeError Traceback (most recent call last)
in ()
3
4 a = np.zeros((3,3))
----> 5 b = torch.from_numpy(a).type(torch.float)

AttributeError: module ‘torch’ has no attribute ‘float’

Which version of pytorch are you using? This was added recently.

I used this to install conda install pytorch=0.1.12 cuda75 -c pytorch following https://pytorch.org/previous-versions/. Do you mean that torch.float and torch.FloatTensor are the same ?

For most purposes yes they are the same. torch.float did not exist in 0.1 though so you will need to upgrade pytorch to be able to use it.