model = nn.Sequential(
nn.Conv2d(3, 32, (3, 3), padding=‘same’),
nn.ReLU(),
nn.init.kaiming_uniform_()
nn.BatchNorm2d(32)
)
nn.BatchNorm2d(32)
^
SyntaxError: invalid syntax
model = nn.Sequential(
nn.Conv2d(3, 32, (3, 3), padding=‘same’),
nn.ReLU(),
nn.init.kaiming_uniform_()
nn.BatchNorm2d(32)
)
nn.BatchNorm2d(32)
^
SyntaxError: invalid syntax
The syntax error is raised because of the usage of nn.init.kaiming_uniform_()
without a comma afterwards.
Remove the nn.init.kaiming_uniform_()
call since this is an inplace function on a tensor and it should work.
If you want to initialize parameters of the model, use the model.apply
method or call the nn.init
methods on parameters directly after creating the object.