I installed an older version of fastai (2.6.0) which dates back to about when the 06_multicat.ipynb notebook was published and for that version, learn.model(x) returns a TensorBase object, so something must have changed since then in how learn.model returns data.
As a workaround, I converted activs to a TensorBase object so that i can pass it to the loss function:
You’re probably seeing the error because of a mismatch in input shapes or data types. BCEWithLogitsLoss() expects the inputs to be the same shape, and y should be of type float32, not long. Also, make sure activs contains raw logits (not passed through a sigmoid already).
Here’s a quick fix:
Ensure y = y.float() if it’s an integer type.
Check that activs and y have the same shape.