MCPcopy Create free account
hub / github.com/ddbourgin/numpy-ml / he_uniform

Function he_uniform

numpy_ml/neural_nets/utils/utils.py:864–892  ·  view source on GitHub ↗

Initializes network weights `W` with using the He uniform initialization strategy. Notes ----- The He uniform initializations trategy initializes thew eights in `W` using draws from Uniform(-b, b) where .. math:: b = \sqrt{\\frac{6}{\\text{fan_in}}} Devel

(weight_shape)

Source from the content-addressed store, hash-verified

862
863
864def he_uniform(weight_shape):
865 """
866 Initializes network weights `W` with using the He uniform initialization
867 strategy.
868
869 Notes
870 -----
871 The He uniform initializations trategy initializes thew eights in `W` using
872 draws from Uniform(-b, b) where
873
874 .. math::
875
876 b = \sqrt{\\frac{6}{\\text{fan_in}}}
877
878 Developed for deep networks with ReLU nonlinearities.
879
880 Parameters
881 ----------
882 weight_shape : tuple
883 The dimensions of the weight matrix/volume.
884
885 Returns
886 -------
887 W : :py:class:`ndarray <numpy.ndarray>` of shape `weight_shape`
888 The initialized weights.
889 """
890 fan_in, fan_out = calc_fan(weight_shape)
891 b = np.sqrt(6 / fan_in)
892 return np.random.uniform(-b, b, size=weight_shape)
893
894
895def he_normal(weight_shape):

Callers

nothing calls this directly

Calls 1

calc_fanFunction · 0.85

Tested by

no test coverage detected