This occurs when running pl.LightningModule.to_torchscript, when, in the forward method of the model, there is an instantiation of a nn class, like nn.Upsample. Perhaps, the instantiation needs to happen in the model's __init__ method.
FrontendError: Cannot instantiate class 'Upsample' in a script function:
File "/kaggle/sartorius_cell_instance_segmentation_kaggle/seggit/models/watershed_transform_net.py", line 47
x = self.fcn(x)
x = nn.Upsample(input_size)(x)
~~~~~~~~~~~ <--- HERE
return x
This occurs when running
pl.LightningModule.to_torchscript
, when, in theforward
method of the model, there is an instantiation of ann
class, likenn.Upsample
. Perhaps, the instantiation needs to happen in the model's__init__
method.