diff --git a/ppdet/modeling/initializer.py b/ppdet/modeling/initializer.py index 96f5eee2f8898e14aea518f1354d829c46a0392d..ce5dea95ab356014731edcd6c2b2d7c6207ab936 100644 --- a/ppdet/modeling/initializer.py +++ b/ppdet/modeling/initializer.py @@ -13,6 +13,7 @@ # limitations under the License. import math +import numpy as np import paddle import paddle.nn as nn @@ -136,7 +137,7 @@ def _calculate_fan_in_and_fan_out(tensor, reverse=False): receptive_field_size = 1 if tensor.ndim > 2: - receptive_field_size = math.prod(tensor.shape[2:]) + receptive_field_size = np.prod(tensor.shape[2:]) fan_in = num_input_fmaps * receptive_field_size fan_out = num_output_fmaps * receptive_field_size