Type error in (torch.cuda.FloatTensor) trying a csv/image dataset caused by a space in a label name


(Roger van Asselt) #1

I have the following error:

Invalid type error in (torch.cuda.FloatTensor) while running learn.fit.

What did I do:

  1. downloaded Style Color images and csv file from Kaggle
  2. adapted the csv file a little so the first column is the Id
  3. used the resnet34 architecture (is the only directly available in Paperspace?)

Everything works fine until I start learn.fit and have the a.m. error.

Where to look to solve this? Thanks for your help.


(Amrit ) #2

Sharing the error code and the code you are using, copy and paste and placing them in or copying and pasting an image would help others better help you resolve this issue.


(Roger van Asselt) #3

I added the notebook so you can follow my steps.

ForumQuestion.pdf (133.6 KB)

Finally it gives the error:

TypeError: eq received an invalid combination of arguments - got (torch.cuda.FloatTensor), but expected one of:

  • (int value)
    didn’t match because some of the arguments have invalid types: (torch.cuda.FloatTensor)
  • (torch.cuda.ByteTensor other)
    didn’t match because some of the arguments have invalid types: (torch.cuda.FloatTensor)

Regards, Roger


(Amrit ) #4

@RogerCulemborg thanks for sharing your code, the error message on the pdf seems to be cut off at the end of page 6.

On the jupyter notebook there should be a create/edit Gist of notebook, please look here as I had to learn the same :slight_smile:

Try sharing that way and I will better be able to help.


(Sarada Lee) #5

@RogerCulemborg Just in case, you can’t find Gist on the toolbar. You need to install Jupyter Notebook Extension.


(Roger van Asselt) #6

Dear Amrit,

Thanks for being so helpful, please find my gist below:

fastai/courses/dl1/lesson2_product_rva-forum.ipynb


(Roger van Asselt) #7

Dear Amrit,

I changed some input especially sz value to 224 because that value is used by resnet (found this while reading your annotated notebook). However, now I got “Expected more than 1 value per channel” error.
With bs=4 I get the torch.cuda.FloatTensor back.

Expected more than 1 value per channel


(Amrit ) #8

Can’t say that I see any issues with your code. It may be a Pytorch issue. What version of Pytorch are you running?

check this post right at the end:

hope that helps


(Roger van Asselt) #9

print(torch.version)
0.3.0.post4

Seems to be the latest version…


(Amrit ) #10

@RogerCulemborg any luck yet?

I checked my version of torch and its 0.2.0_4. If not resolved do you want to try to downgrade to this version and see if it works?

http://pytorch.org/previous-versions/


(Roger van Asselt) #11

Solved!

  • downgrading --> no succes
  • another architecture --> no succes

I uses another dataset (“invasive-species-monitoring”) --> works fine, also with different architectures

Conclusion: something wrong in the dataset
I studied dataset.py and found splitting by spaces
I reviewed the csv file and found a space in one label
Replaced “nail polish” by “nail_polish” --> and everything works fine!

Suggestion: please add some help text to ImageClassifierData.from_csv about the format which is expected form the csv file, because I see quite different formats on Kaggle.

Thanks for your help.