<p>According to <a href="https://arxiv.org/pdf/1502.01852v1.pdf" rel="nofollow">He et al 2015</a> Eq. 15, the theoretical weight variance for one layer when using ReLu becomes:</p>

<pre><code>n*Var[W] = 2
</code></pre>

<p>where n is the layer size. </p>

<p>If you want to use pooled variance of both the in layer and the out layer, then it becomes:</p>

<pre><code>(fan_in, fan_out) = ...
low = -2*np.sqrt(1.0/(fan_in + fan_out))
high = 2*np.sqrt(1.0/(fan_in + fan_out))
</code></pre>

<p>If you are using tensorflow, they have a <a href="https://www.tensorflow.org/versions/r0.11/api_docs/python/contrib.layers.html#variance_scaling_initializer" rel="nofollow">variance_scaling_initializer</a>, where you can set the factor variable and the mode variable to control how you want the initialization to be.</p>

<p>If you use the default setting of argument factor=2.0 for this initializer, you'll get the initialization variances suggested by He et al 2015 for ReLu activation. Although you can play around with the argument mode to get slightly different weight initialization variances. Only use in layer:</p>

<pre><code>tf.contrib.layers.variance_scaling_initializer(factor=2.0, mode='FAN_IN') 
</code></pre>

<p>would give you following:</p>

<pre><code>(fan_in, fan_out) = ...
low = -np.sqrt(2.0/fan_in)
high = np.sqrt(2.0/fan_in)
</code></pre>

<p>Use both in and out layers:</p>

<pre><code>tf.contrib.layers.variance_scaling_initializer(factor=2.0, mode='FAN_AVG')
</code></pre>

<p>would give you:</p>

<pre><code>(fan_in, fan_out) = ...
low = -np.sqrt(4.0/(fan_in+fan_out)) = -2.0*np.sqrt(1.0/(fan_in+fan_out))
high = np.sqrt(4.0/(fan_in+fan_out)) = 2.0*np.sqrt(1.0/(fan_in+fan_out))
</code></pre>

<p>Only use out layer:</p>

<pre><code>tf.contrib.layers.variance_scaling_initializer(factor=2.0, mode='FAN_AVG')
</code></pre>

<p>would give you:</p>

<pre><code>(fan_in, fan_out) = ...
low = -np.sqrt(2.0/fan_out)
high = np.sqrt(2.0/fan_out)
</code></pre>
Hand crafted Xavier Initializer: Which values for lrelu and relu
<p>As a followup to a reply (not the chosen one) in <a href="https://stackoverflow.com/questions/33640581/how-to-do-xavier-initialization-on-tensorflow">How to do Xavier initialization on TensorFlow</a>: Anyone having an idea, which values to use in relu and especially leaky relu?</p>

<p>I mean this part:</p>

<pre><code># use 4 for sigmoid, 1 for tanh activation
</code></pre>

<p>This was given there:</p>

<pre><code>(fan_in, fan_out) = ...
    low = -4*np.sqrt(6.0/(fan_in + fan_out)) # use 4 for sigmoid, 1 for tanh activation 
    high = 4*np.sqrt(6.0/(fan_in + fan_out))
    return tf.Variable(tf.random_uniform(shape, minval=low, maxval=high, dtype=tf.float32))
</code></pre>