Sorry for the misleading code. It should be: if m.bias is not None:
Also, xavier_uniform will fail on bias, as it has less than 2 dimensions, so that fan_in and fan_out cannot be computed.
if isinstance(m, nn.Conv2d):
    torch.nn.init.xavier_uniform_(m.weight)
    if m.bias is not None:
        torch.nn.init.zeros_(m.bias)