huiyegit / T2I_CL

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Weight initialization problem

YIRuriZhongtian opened this issue · comments

hi, I noticed that the code when initializing the weights is different from AttnGAN. Can you tell me the reason for doing this?

if classname.find('Conv') != -1:
#print(m.state_dict().keys())
if list(m.state_dict().keys())[0] == 'weight':
nn.init.orthogonal_(m.weight.data, 1.0)
elif m.state_dict().keys()[3] == 'weight_bar':
nn.init.orthogonal_(m.weight_bar.data, 1.0)

I think the weights may have the Dictionary type to store them, then we can use different keys (.i.e ''weight'' and ''weight_bar'') to get the values(weights).

Thank you for your reply. Sorry, I still don’t understand the difference between these two.

    if classname.find('Conv') != -1:
        nn.init.orthogonal_(m.weight.data, 1.0)

Can I think that they have the same effect?

I think so. It is the same way to initialize the weight of 'Conv' layer.

ok, thank you!