Hello everyone,
I've updated the notebook for HW2:
https://github.com/WeizmannML/course2019/blob/master/Tutorial2/tutorial2...
there were 2 issues:
1. if you ran on a gpu, in the section were I constructed a custom model that returns a "constant" output, that output was not placed on the GPU and that would cause a problem when you try to use the model. I've updated that section with an explanation and added a custom model that actually works (it's essentially a copy of the fastai tabular model).
2. for some reason replacing the model by doing
learn.model = net
was not interacting well with the automatic learning rate finder. so i've shown the proper way to do it, sorry for not noticing that problem sooner.
If you still have issues with the homework please contact us or post here,
thanks,
Jonathan
Dear Jonathan
I still have this issue.
#lets see what kind of categories we have (there are 4 possible values, 5 if we include 0)
cat_x_values = cat_x.data.numpy().flatten()
plt.hist(cat_x_values , bins=np.linspace(-0.75,6.25,15) )
plt.show()
print(set( cat_x_values))
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
<ipython-input-23-bb1ca1a506cc> in <module>() ----> 1 cat_x_values = cat_x.data.numpy().flatten() 2 3 plt.hist(cat_x_values , bins=np.linspace(-0.75,6.25,15) ) 4 plt.show() 5 print(set( cat_x_values))
TypeError: can't convert CUDA tensor to numpy. Use Tensor.cpu() to copy the tensor to host memory first.
Hi Anton,
sorry about that, I keep adding things to the notebook and not checking all of them on colab. my mistake.
simply replace
cat_x.data.numpy().flatten()
with
cat_x.cpu().data.numpy().flatten()
as the error message says, if the tensor is on the gpu, and you try to convert it to a numpy array, it will not allow that (since numpy arrays can't live on the gpu memory). and the method .cpu() applied to a pytorch tensor will put it on the cpu memory.
Thank you, Jonathan
It is work now!
Best regards