Is there a way to alter this code for a situation where you have nn.Conv2d layers whos bias can be on or off depending on their position in the network?
e.g. you have a first Conv2d with a bias term but then a later Conv2d with no bias term.
As the following will return an error:
    if isinstance(m, nn.Conv2d(bias=True):
        xavier(m.weight.data)
        xavier(m.bias.data)