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

train error /KeyError: 'module name can\'t contain ".", got: layer2.leakyrelu' #64

Open
gyx-tail opened this issue Oct 12, 2022 · 3 comments

Comments

@gyx-tail
Copy link

When I run the train.py,show this
Traceback (most recent call last):
File "train.py", line 118, in
netG = net.dehaze(inputChannelSize, outputChannelSize, ngf)
File "/mnt/e/PycharmProject/DCPDN-master/models/dehaze22.py", line 665, in init
self.tran_est=G(input_nc=3,output_nc=3, nf=64)
File "/mnt/e/PycharmProject/DCPDN-master/models/dehaze22.py", line 216, in init
layer2 = blockUNet(nf, nf*2, name, transposed=False, bn=True, relu=False, dropout=False)
File "/mnt/e/PycharmProject/DCPDN-master/models/dehaze22.py", line 56, in blockUNet
block.add_module('%s.leakyrelu' % name, nn.LeakyReLU(0.2, inplace=True))
File "/home/gyx1999/anaconda3/envs/pytorchgpu/lib/python3.8/site-packages/torch/nn/modules/module.py", line 380, in add_module
raise KeyError("module name can't contain ".", got: {}".format(name))
KeyError: 'module name can't contain ".", got: layer2.leakyrelu'
How can I solve this problem

@DMNQYQ
Copy link

DMNQYQ commented Apr 11, 2023

请问你解决了吗 我也遇到了这样的问题

@yogurtbuddy
Copy link

请问你解决了吗 我也遇到了这样的问题

dahaze22中,block module 把里面的参数%d后面的点删掉就行,

@ZhuLiangyu123
Copy link

请问你解决了吗 我也遇到了这样的问题

将%s.leakyrelu' % name修改为%s_leakyrelu' % name即可。

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

4 participants