当前位置:网站首页>After the model is created, initialize the variables in con2d, convtranspose2d, and normalized batchnorm2d functions

After the model is created, initialize the variables in con2d, convtranspose2d, and normalized batchnorm2d functions

2022-06-23 16:15:00 Growth of code Xiaobai

 def weights_init(m):
     classname = m.__class__.__name__
     if (classname.find('Conv2d') != -1) | (classname.find('ConvTranspose2d') != -1):
         m.weight.data.normal_(0.0, 0.02)
     elif classname.find('BatchNorm2d') != -1:
         m.weight.data.normal_(1.0, 0.02)
         m.bias.data.fill_(0)

#  Defining models 
m = model()
m.cuda()
#  Model initialization 
weights_init(m)
原网站

版权声明
本文为[Growth of code Xiaobai]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/174/202206231508506567.html