Ponx
Ponx

Reputation: 97

How to initialize with same weights in tensorflow?

I am building a CNN model with tensorflow and I wanted to know if it is possible to set somehow a seed for weights initialization in order to be able to have everywhere the same seed so that I can compare between different architectures of my model. Found answers on stack overflow like this Tensorflow weight initialization but didn't really help me so your help will be appreciated. Thanks in advance!

Upvotes: 4

Views: 3808

Answers (1)

user8879803
user8879803

Reputation:

You can set the kernel_initializer in all the layers as per your requirement. The term kernel_initializer is a fancy term for which statistical distribution or function is used for initialising the weights.

The initializer can take different values. You can set them all zeros, ones or a constant value. You can also choose RandomUniform or RandomNormal with the seed value.

If you are using tensorflow for layer, then you can find details about different initializers here - Tensorflow Initialzer

If you are using Keras for layer, then you can find details about different initializers here - Keras Initializer

Upvotes: 3

Related Questions