From 921702768740f02930370888ac14941e6d415ab0 Mon Sep 17 00:00:00 2001 From: Bing Xu Date: Mon, 16 May 2016 14:50:27 -0700 Subject: [PATCH] Update initializer.py (#2163) Make Xaiver(out, xxx) same to Torch --- python/mxnet/initializer.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/python/mxnet/initializer.py b/python/mxnet/initializer.py index fd29da7d..3d594434 100644 --- a/python/mxnet/initializer.py +++ b/python/mxnet/initializer.py @@ -235,8 +235,11 @@ def __init__(self, rnd_type="uniform", factor_type="avg", magnitude=3): def _init_weight(self, _, arr): shape = arr.shape - fan_in, fan_out = np.prod(shape[1:]), shape[0] - factor = 1 + hw_scale = 1. + if len(shape) > 2: + hw_scale = np.prod(shape[2:]) + fan_in, fan_out = shape[1] * hw_scale, shape[0] * hw_scale + factor = 1. if self.factor_type == "avg": factor = (fan_in + fan_out) / 2.0 elif self.factor_type == "in":