MCPcopy Create free account
hub / github.com/OpenGVLab/HumanBench / c2_xavier_fill

Function c2_xavier_fill

PATH/core/models/ops/utils.py:100–114  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

98
99
100def 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
117def c2_msra_fill(module: nn.Module) -> None:

Callers 7

__init__Method · 0.90
__init__Method · 0.90
__init__Method · 0.90
__init__Method · 0.90
__init__Method · 0.90
__init__Method · 0.90
__init__Method · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected