我看到xavier_initializer()
的以下解释。它表示var(wi) = 1/Navg
在实际实施过程中接受输入神经元的数量。
https://prateekvjoshi.com/2016/03/29/understanding-xavier-initialization-in-deep-neural-networks/
但是,在以下示例中,没有神经元。我计算了W的方差。有人知道它的方差是根据xavier_initializer()
确定的吗?谢谢!
$ cat main.py
#!/usr/bin/env python
# vim: set noexpandtab tabstop=2 shiftwidth=2 softtabstop=-1 fileencoding=utf-8:
import tensorflow as tf
W = tf.get_variable("W", shape=[5], initializer=tf.contrib.layers.xavier_initializer())
init = tf.global_variables_initializer()
import numpy
with tf.Session() as sess:
sess.run(init)
print numpy.var(W.eval())
$ ./main.py
0.166031
答案 0 :(得分:0)
如果我像这样修改你的代码,你还有问题吗?
import numpy as np
import tensorflow as tf
W = tf.get_variable("W", shape=[5],initializer=tf.contrib.layers.xavier_initializer())
init = tf.global_variables_initializer()
with tf.Session() as sess:
sess.run(init)
w_value = sess.run(W)
print w_value
print np.var(w_value)