Closed mohsen-saki closed 3 years ago
This is cimpletely normal.
your xresnet
does not know how many outputs your data has. (when you call xresnet18 directly, you are using the default imagenet 1000 classes).
Use the create_cnn
method and explicitely say n_out=1
, replace your model by this:
model = create_cnn_model(xresnet18, n_out=1)
A good practice, is to pass one input on the model manually, and check the output.
x,y = dls.one_batch()
out = model(x)
assert test_eq(out.shape, y.shape)
Cool project, what are you regressing, the wind speed from the image of the storm?
Thanks mate. Worked like a charm (though I did my homework before posting here, could not find a clear and concise explanation) Yep, The project is predicting storm speed from satellite imagery. Nothing new really :) It has been out for a couple of years already.
I suppose I should close this thread. Appreciated your help
Cheers
Issue is occurring with fastai==2.2.5, fastcore==1.3.19, nbdev==1.1.12
Describe the bug When training an
image regression
from scratch using RegressionBlock and MSELossFlat it throws aRuntimeError
that the size of tensors a and b mismatches. It seems that the error is raised by theloss function (MSELossFlat)
.Notes:
pre-trained model
along with RegressionBlock and MSELossFlat work wellcolab
andsagemaker
To Reproduce
dataframe
with two columns; oneimage_path
and othertarget_value
RegressionBlock
xresnet18
andMSELossFlat
Expected behavior To work smoothly as it does for
category problem
orregression with pre-trained model
.Error with full stack trace
Alternatively, see the link above.
Additional context Add any other context about the problem here.