Running ConvLeaner.fit()
after calling unfreeze()
with Precompute=false
and using arch=resnext50
I was running into the error:
TypeError: eq received an invalid combination of arguments - got (numpy.ndarray), but expected one of: * (int value) didn't match because some of the arguments have invalid types: (numpy.ndarray) * (torch.cuda.LongTensor other) didn't match because some of the arguments have invalid types: (numpy.ndarray)
coming from this line of metrics.py when the first epoch of fit
completed. I noticed that @jeremy released a fix for a similar issue here and confirmed that I had this fix locally. It looks like targs
was being set to a numpy
array which couldn’t be compared to the preds
PyTorch Tensor (that was changed in the linked fix). I initially tried calling:
targs = torch.from_numpy(targs)
on line 10 to convert this to a toch.LongTensor
but then received the similar error:
eq received an invalid combination of arguments - got (torch.LongTensor), but expected one of
…
So finally I changed this line to:
targs = torch.from_numpy(targs).cuda()
To get this tensor on the GPU and this succeeded. Hope this helps anyone running into this issue.