Hello all, I have a sequential layer like
self.conv_norm_relu = nn.Sequential(
nn.Conv2d(in_channels, out_channels, kernel_size=3, padding=1),
nn.BatchNorm2d(out_channels),
nn.ReLU(inplace=True))
I want to change nn.BatchNorm2d
to GroupNorm
, so the new one is
self.conv_norm_relu = nn.Sequential(
nn.Conv2d(in_channels, out_channels, kernel_size=3, padding=1),
nn.GroupNorm(16, out_channels),
nn.ReLU(inplace=True))
So, I want to make flexible way that allows to select between GroupNorm
and BatchNorm2d
. A list of normalized method is normalize_method =['GroupNorm'. 'BatchNorm2d']
. If I select normalize_method[0]
then self.conv_norm_relu
will use GroupNorm
, and If I select normalize_method[1]
then self.conv_norm_relu
will use BatchNorm2d
normalize_method =['GroupNorm'. 'BatchNorm2d']
self.conv_norm_relu = nn.Sequential(
nn.Conv2d(in_channels, out_channels, kernel_size=3, padding=1),
#something change here,
nn.ReLU(inplace=True))
Do we have any option to do it?