Keras: Batch normalization layer have 4 parameters.

Created on 21 Jan 2016  路  8Comments  路  Source: keras-team/keras

When I execute model.get_weights() , It seems each BN layer have 4 parameters serially
I believe there are gamma , inverse stdev , Gamma , beta are included.
But I cannot sure the order of the parameter.
what is the first parameter?
what is the second parameter?
what is the third parameter?
what is the fourth parameter?
It will be grateful for me to know.

Most helpful comment

Looks like gamma, beta, running mean and running std is the order (super.get_weights() returns the weights of self.params and then running mean and std are tacked on): https://github.com/fchollet/keras/blob/master/keras/layers/normalization.py#L61-L72

All 8 comments

But I cannot sure the order of the parameter.

Well, read the source code! It's straightforward.

well I read it hours. But I cannot understood. (i'm not good at code.)
please give me a hint.

Looks like gamma, beta, running mean and running std is the order (super.get_weights() returns the weights of self.params and then running mean and std are tacked on): https://github.com/fchollet/keras/blob/master/keras/layers/normalization.py#L61-L72

AvantiShri is right. And you can find the answer from this keras document
https://faroit.github.io/keras-docs/1.2.2/layers/normalization/
It explains weights order is : [gamma, beta, mean, std]
Somehow, another keras document https://keras.io/layers/normalization/ lacks of the note for the 'weights' parameter, which is quit confusing.

Looking at the code : https://github.com/keras-team/keras/blob/master/keras/layers/normalization.py#L61-L72

I think it should be [gamma, beta, mean , variance]

In case of Batch Normalization get_weights() will provide four additional parameter values for each hidden layers in neural network.

Please refer link https://stackoverflow.com/questions/57087273 for more details.

Looks like gamma, beta, running mean and running std is the order (super.get_weights() returns the weights of self.params and then running mean and std are tacked on): https://github.com/fchollet/keras/blob/master/keras/layers/normalization.py#L61-L72

I'm wondering where is this line in source code: super.get_weights()
I know several ppl mentioned that the order is stated in the document, but am I the only one that couldn't find it? Or they just removed the part that you guys once saw.

But I cannot sure the order of the parameter.

Well, read the source code! It's straightforward.

"Straight forward" is subjective & "Read the source code" is not a great reply. Well written and clear code documentation is expected for any usable codebase and what you are saying is that it's OK for many people to be wasting their hours sifting through the codebase..

Was this page helpful?
0 / 5 - 0 ratings