a pytorch beginner need your help! it seems a easy problem but i just can’t solve it
i wana use torch.nn.init.nomal(model.parameters(),mean=0,std=1) to initialize my model, but i got this problem:
AttributeError: ‘generator’ object has no attribute ‘normal_’
my pytorch version is 1.2.0
model.parameters()
return a generator.
An example:
def init_function(module):
if isinstance(module, nn.Conv2d):
nn.init.normal(module.weight, mean=0, std=1)
net = YourNet()
net.apply(init_function)
1 Like
It works! Thank u so much!