神经网络参数初始化

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:
        

你可能感兴趣的:(深度学习宝典,网络参数初始化)