
Jupyter Notebookでkeras.layers.GaussianNoiseを使ってみた所、なんのnoiseも付与されなかったので調べてみた。
まずは公式ドキュメント。
tf.keras.layers.GaussianNoise | TensorFlow v2.16.1
Apply additive zero-centered Gaussian noise.
Call arguments:
inputs: Input tensor (of any rank).
training: Python boolean indicating whether the layer should behave in training mode (adding noise) or in inference mode (doing nothing).
trainの時はadding noiseで、inferenceの時はdoing nothingという挙動になるらしい。
model.trainしたら効果があるが、Jupyter Notebookでお試し動作をしている分には効果が確認できない。
明示的にtrainingにする方法がないのか?今度はkerasの公式サイトを見てみる。

Keras documentation: Page not found
Keras documentation
set_learning_phase
keras.backend.set_learning_phase(value)
値を固定化するための学習フェーズをセットします.
バックエンドを学習フェーズで動作させる関数があった。
tf.keras.backend.set_learning_phase(1)
これでJupyter NotebookでGaussianNoiseの効果を確かめることが出来るようになった。
参考

Keras GaussianNoise layer no effect?
I wanted to add some Gaussian noise to my Images in my CNN with the keras's functional API, but while testing some diffe...
コメント