Skip to content
Advertisement

RuntimeError: Found dtype Char but expected Float

I am using PyTorch in my program(Binary Classification).

The output from my model and actual labels are

JavaScript

When I calculate the Binary Cross Entropy, it gives me the error

JavaScript

I have no idea how it is finding the Char dtype.

Even If calculate it manually, it gives me this error.

JavaScript

My DataLoader is

JavaScript

my training loop is

JavaScript

And my Model is

JavaScript

How to overcome it.

EDIT

Trace back on train_model function:

JavaScript

Trace back on calculating loss individually

JavaScript

Advertisement

Answer

BCELoss() expects float labels. Yours are int8 (aka char). Converting them to float in the last line of__getitem__()should fix the issue.

User contributions licensed under: CC BY-SA
9 People found this is helpful
Advertisement