I’m unable to import ‘weak_module’ from ‘torch._jit_internal’. It says 'ImportError: cannot import name ‘weak_module’. I’m using Pytorch 1.3.0a0+24ae9b5 version. Please help me.
This is some internal module, it might have been removed/renamed. Why do you want to use it?
I’m trying to run EfficientNet which has used the module in the following manner.
‘from torch._jit_internal import weak_module, weak_script_method’
Which EfficientNet implementation are you using? The decorators its pulling from
_jit_internal were deleted in v1.2. Their functionality is now automatic, so they can just be deleted and everything should work the same.
I’m using the implementation which is given here https://github.com/katsura-jp/efficientnet-pytorch
It should work if you apply this patch
diff --git a/model/swish.py b/model/swish.py index 66adfa5..3f68678 100644 --- a/model/swish.py +++ b/model/swish.py @@ -1,10 +1,8 @@ import torch import torch.nn as nn from torch.nn.parameter import Parameter -from torch._jit_internal import weak_module, weak_script_method -@weak_module class Swish(nn.Module): def __init__(self, train_beta=False): super(Swish, self).__init__() @@ -13,7 +11,6 @@ class Swish(nn.Module): else: self.weight = 1.0 - @weak_script_method def forward(self, input): return input * torch.sigmoid(self.weight * input)
Where to apply this patch? I’m unable to find the corresponding file from where i have used it as ‘from torch._jit_internal’.
He refers to this file in the repo you linked above.