《TensorFlow 实战》黄文坚 黄源著
源码地址:https://github.com/sundaygeek/tensorflow-in-action/blob/master/5_2_CNN_MNIST.py
def weight_variable(shape):
initial = tf.truncated_normal(shape, stddev=0.1)
return tf.Variable(initial)
如果该函数中的初始化函数 tf.truncated_normal(shape, stddev=0.1) 不设置参数 stddev 的话,训练精度最多只能到 20% 左右,即使调整优化器的学习了到很大,训练精度也不会超过 20%
参数 stddev 用于设置正太分布被截断前的标准差,设置了 stddev=0.1 后,训练精度就达到达到 99.2% 以上
神经网络参数初始化也很重要呀!!!