Patrick Lehnen
Patrick Lehnen

Reputation: 80

Change Keras Standard Deviation of Gaussian Noise Layer while training

What is the fastest way to change the standard deviation of a Gaussian noise layer in Keras during training?

Currently I am reloading the whole network with the adapted standard deviation every iteration, which is really slow.

Thank you in advance!

Upvotes: 2

Views: 497

Answers (1)

Achintha Ihalage
Achintha Ihalage

Reputation: 2440

Can you try using keras backend variables?

from keras import backend as K

self.std=0.5
self.std_var = K.variable(value=std)

When building the network.

# instantiate
stddev = std_var(0.8)
g = GaussianNoise(stddev)

During training (possibly inside a loop).

K.set_value(stddev.std_var, <new_std_val>)

Try this snippet and see whether it works.

Upvotes: 1

Related Questions