def _upsample(self, x, y, scale=1):
_, _, H, W = y.size()
return F.interpolate(x, size=(H // scale, W // scale), mode='bilinear',align_corners=True)
转torchscript格式时报如下错误:
Expected a value of type 'Tensor (inferred)' for argument 'scale' but instead found type 'int'.
Inferred 'scale' to be of type 'Tensor' because it was not annotated with an explicit type.
你若果确实要传整型,改成
def _upsample(self, x, y, scale:int=1):
_, _, H, W = y.size()
return F.interpolate(x, size=(H // scale, W // scale), mode='bilinear',align_corners=True)