Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tensor mismatch in lesson 2 #225

Closed
SteveFaultless opened this issue Mar 18, 2018 · 2 comments
Closed

Tensor mismatch in lesson 2 #225

SteveFaultless opened this issue Mar 18, 2018 · 2 comments

Comments

@SteveFaultless
Copy link

Hi,

I get a tensor mismatch in lesson 2 when I try to run lrf=learn.lr_find()

Lesson two variable mismatch runtime error

Apparently, the data.val_dl tensor is a LongTensor where learn.lr_find() expects a FloatTensor.

I was able to fix this by going to

courses/dl1/fastai/dataset.py

And adding:

    y = y.astype(float)

At line 433.

I'm not sure that this is the best solution, and I don't know if it will negatively affect anything else because I'm new to the fastai library. I could just as easily have added

    label_arr = label_arr.astype(float)

at line 153, I think.

I am running fastai using a docker image hosted in ubuntu 16.04. I can provide any other details you may need.

@SteveFaultless
Copy link
Author

Looking at the commit history, it seems that the error is caused by this commit: 98fad0e

 def n_hot(ids, c):
-    res = np.zeros((c,), dtype=np.float32)
+    res = np.zeros((c,), dtype=np.int8)
     res[ids] = 1
     return res

The change to np.int8 appears to have caused the problem. I changed it back to float (while removing my workaround above) and it worked fine.

@jph00
Copy link
Member

jph00 commented Mar 20, 2018

Yup fixed now.

@jph00 jph00 closed this as completed Mar 20, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants