How to initial the layers weight in nn.Sequential

suppose I have the code like this

submodel = nn.Sequential(
				nn.Conv2d(
					in_channels=inplanes,
					out_channels=inplanes,
					kernel_size=3,
					stride=1,
					padding=padding,
					dilation=dilation,
					bias=True
				),
				nn.Conv2d(
					in_channels=inplanes,
					out_channels=inplanes,
					kernel_size=1,
					stride=1
				),
				nn.Conv2d(
					in_channels=inplanes,
					out_channels=outplanes,
					kernel_size=1,
					stride=1
				)

how to initial this submodel in the nn.Sequential object

		for m in self.modules():
			if isinstance(m, nn.Conv2d):
				nn.init.normal(m.weight, mean=0, std=0.01)
				nn.init.constant(m.bias, 0)
1 Like