神经网络参数初始化

x33g5p2x  于2022-04-25 转载在 其他  
字(0.6k)|赞(0)|评价(0)|浏览(333)

pytorch:

class FaceBox_s(nn.Module):

	def init_params(self):
		for m in self.modules():
			if isinstance(m, nn.Conv2d):
				nn.init.xavier_uniform_(m.weight)
				if m.bias is not None:
					nn.init.constant_(m.bias, 0)
			elif isinstance(m, nn.BatchNorm2d):
				nn.init.constant_(m.weight, 1)
				nn.init.constant_(m.bias, 0)
			elif isinstance(m, nn.Linear):
				nn.init.normal_(m.weight, std=0.001)
				if m.bias is not None:
					nn.init.constant_(m.bias, 0)

pytorch 初始化权重_AI视觉网奇的博客-CSDN博客

初始化参数为0:

def init_params(self):
        for m in self.modules():
            if isinstance(m, nn.Conv2d):
                nn.init.constant_(m.weight, 0)
                # nn.init.xavier_uniform_(m.weight)
                if m.bias is not None:

相关文章