Reputation: 2698
I initially set my weights as follows:
def new_weights(shape):
return tf.Variable(tf.truncated_normal(shape, stddev=0.05))
But I realized that I had weights -0 as in the following figure:
Then I decided to define it that way, and for me the weights are more acceptable:
def new_weights(shape):
return tf.Variable(tf.zeros(shape))
I want to know what the implication of using tf.truncated_normal is and what does the -zeros mean? And if you have any problems initializing them like this.
And between the two I introduced, what would be the best method of initializing weights?
Upvotes: 0
Views: 1444
Reputation: 1829
tf.truncated_normal outputs random values from a truncated normal distribution. Therefore, have good convergence properties in DNN. Following graphs are the validation loss (left) and validation accuracy (right) of a CNN on MNIST dataset. Used weight initializations are as follows,
As you can see, random weights on the scale of -1 to +1 have shown good results. Therefore, it is the most commonly used weight initialization method in DNN.
References, https://medium.com/@amarbudhiraja/towards-weight-initialization-in-deep-neural-networks-908d3d9f1e02
Upvotes: 1