megengine.module.init.calculate_fan_in_and_fan_out¶
- calculate_fan_in_and_fan_out(tensor)[source]¶
Calculates fan_in / fan_out value for given weight tensor. This function assumes input tensor is stored in
NCHW
format.Note
The group conv2d kernel shape in MegEngine is
(G, O/G, I/G, K, K)
. This function calculatesfan_out = O/G * K * K
as default, but PyTorch usesfan_out = O * K * K
.