I was reading Chapter 6 and encounter this error:
RuntimeError: Input type (torch.cuda.FloatTensor) and weight type (torch.FloatTensor) should be the same
This is caused by the following code:
learn = cnn_learner(dls, resnet18)
x,y = dls.train.one_batch()
activs = learn.model(x) <------- This line throw the error
activs.shape
I find the updated version of fastbook and found that the code is updated as follow:
learn = cnn_learner(dls, resnet18)
x,y = to_cpu(dls.train.one_batch())
activs = learn.model(x)
activs.shape
What is the new to_cpu() doing?
I looked up the documentation and it said: Recursively map lists of tensors in b to the cpu.
What does that mean?
I tried to do x?
in the old version and it said
Type: TensorImage
String form:
TensorImage([[[[ 0.9817, 0.9817, 0.9817, ..., 1.0159, 1.0159, 1.0159],
[ 0.9817, <...> 622],
[ 0.3742, 0.3916, 0.3742, ..., 0.8971, 0.7751, 0.5834]]]], device='cuda:0')
Since there’s a device=cuda, that means the older version tensor x is in the GPU?
Adding to_cpu() will remove that field in the x?
output.
Also, which one is the weight type that have (torch.FloatTensor)??
Is it the weight/parameters in resnet18?
Additional question, How do I update my version of fastbook in paperspace gradient to the lastest version in github?