Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

KeyError: 'module name can\'t contain "."' #8

Open
TimDNN opened this issue Oct 31, 2018 · 3 comments
Open

KeyError: 'module name can\'t contain "."' #8

TimDNN opened this issue Oct 31, 2018 · 3 comments

Comments

@TimDNN
Copy link

TimDNN commented Oct 31, 2018

Hello,
The Feature extraction doesn't work anymore.
Probably because they changed the names of the Layers.
Unfortantly it doesn't work with anny of the models.

Can someone help with one Model?
For now I just want to get the code running, so I don't care what Model will be working ;-)

This is the Full Error Message:
/home/user/pspnet_pytorch/lib/python3.5/site-packages/torchvision/models/densenet.py:212: UserWarning: nn.init.kaiming_normal is now deprecated in favor of nn.init.kaiming_normal_. nn.init.kaiming_normal(m.weight.data) Traceback (most recent call last): File "/home/user/PycharmProjects/pspnet_pytorch/pspnet-pytorch-master/train.py", line 101, in <module> train() File "/home/user/pspnet_pytorch/lib/python3.5/site-packages/click/core.py", line 764, in __call__ return self.main(*args, **kwargs) File "/home/user/pspnet_pytorch/lib/python3.5/site-packages/click/core.py", line 717, in main rv = self.invoke(ctx) File "/home/user/pspnet_pytorch/lib/python3.5/site-packages/click/core.py", line 956, in invoke return ctx.invoke(self.callback, **ctx.params) File "/home/user/pspnet_pytorch/lib/python3.5/site-packages/click/core.py", line 555, in invoke return callback(*args, **kwargs) File "/home/user/PycharmProjects/pspnet_pytorch/pspnet-pytorch-master/train.py", line 57, in train net, starting_epoch = build_network(snapshot, backend) File "/home/user/PycharmProjects/pspnet_pytorch/pspnet-pytorch-master/train.py", line 31, in build_network net = models[backend]() File "/home/user/PycharmProjects/pspnet_pytorch/pspnet-pytorch-master/train.py", line 19, in <lambda> 'densenet': lambda: PSPNet(sizes=(1, 2, 3, 6), psp_size=1024, deep_features_size=512, backend='densenet'), File "/home/user/PycharmProjects/pspnet_pytorch/pspnet-pytorch-master/pspnet.py", line 47, in __init__ self.feats = getattr(extractors, backend)(pretrained) File "/home/user/PycharmProjects/pspnet_pytorch/pspnet-pytorch-master/extractors.py", line 330, in densenet return DenseNet(pretrained=pretrained) File "/home/user/PycharmProjects/pspnet_pytorch/pspnet-pytorch-master/extractors.py", line 230, in __init__ bn_size=bn_size, growth_rate=growth_rate, drop_rate=drop_rate) File "/home/user/PycharmProjects/pspnet_pytorch/pspnet-pytorch-master/extractors.py", line 187, in __init__ layer = _DenseLayer(num_input_features + i * growth_rate, growth_rate, bn_size, drop_rate) File "/home/user/PycharmProjects/pspnet_pytorch/pspnet-pytorch-master/extractors.py", line 166, in __init__ self.add_module('norm.1', nn.BatchNorm2d(num_input_features)), File "/home/user/pspnet_pytorch/lib/python3.5/site-packages/torch/nn/modules/module.py", line 178, in add_module raise KeyError("module name can't contain \".\"") KeyError: 'module name can\'t contain "."'

@muaz-git
Copy link

@TimDNN I am facing the same issue. Any luck so far?

@TimDNN
Copy link
Author

TimDNN commented Nov 19, 2018

@muaz-git unfortunately not =(
did u find out annything?

@muaz-git
Copy link

@TimDNN well yes. As ResNet (extractor) architecture has been modified a bit in the pytorch git.
So, I wrote my own code to load weights which fits with the layer name and ignore the weights for the layers which are not available.
Or you can just update the code of extractors.py from here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants