PyTorch assumes that the first argument to a method has the “right” dtype and thus claims that Long is expected in the model parameter.
However, you should use FloatTensors to train the model in order to be able to calculate gradients (which are defined for floating point types).
Transform the data and target thus via float() and this error should be resolved.
However, your code will still not be working, since nn.BCELoss expects the model output to be in [0, 1] so apply a sigmoid on the model output or use nn.BCEWithLogitsLoss instead, which also increases the numerical stability.
Also, loss.backward() won’t work and you should replace it with l.backward().