Initialize `module.weight` using the "XavierFill" implemented in Caffe2. Also initializes `module.bias` to 0. Args: module (torch.nn.Module): module to initialize.
(module: nn.Module)
| 98 | |
| 99 | |
| 100 | def c2_xavier_fill(module: nn.Module) -> None: |
| 101 | """ |
| 102 | Initialize `module.weight` using the "XavierFill" implemented in Caffe2. |
| 103 | Also initializes `module.bias` to 0. |
| 104 | |
| 105 | Args: |
| 106 | module (torch.nn.Module): module to initialize. |
| 107 | """ |
| 108 | # Caffe2 implementation of XavierFill in fact |
| 109 | # corresponds to kaiming_uniform_ in PyTorch |
| 110 | nn.init.kaiming_uniform_(module.weight, a=1) |
| 111 | if module.bias is not None: |
| 112 | # pyre-fixme[6]: Expected `Tensor` for 1st param but got `Union[nn.Module, |
| 113 | # torch.Tensor]`. |
| 114 | nn.init.constant_(module.bias, 0) |
| 115 | |
| 116 | |
| 117 | def c2_msra_fill(module: nn.Module) -> None: |