Reputation: 21
I build a CNN model based on this tutorial: https://www.tensorflow.org/tutorials/layers
However, I suspect that my model is sensitive to initialization of weights, because sometimes the model can run, but sometimes it gives NAN error. Hence, I'd like to initialize weights of my choice. How can I initialize weights in this case?
Upvotes: 0
Views: 1700
Reputation: 5722
In general, you will need to define initializer when you define the model. For canned Estimators, you don't have access to their initializer. If you define your own model_fn
, you can make use of kernel_initializer
an bias_initializer
for tf.layers.conv2d
and tf.layers.dense
. Tensorflow has a tf.initializers
module which allows you to define your own initializer. For example, if you have specific values in mind, you can use tf.constant_initializer(init_value)
to initialize weights of your choice.
Upvotes: 1