Quantcast
Viewing all articles
Browse latest Browse all 14389

Usage of 'learning_phase' in keras for tensorflow backend?

I am trying to train a resnet network using keras backend in tensorflow. The feed dictionary for each batch update is written as:

    feed_dict= {x:X_train[indices[start:end]], y:Y_train[indices[start:end]], keras.backend.learning_phase():1}

I am using keras backend (keras.backend.set_session(sess)) because the original resnet network is defined with keras. As the model contains dropout and batch_norm layers, it requires a learning phase to distinct between training and testing.

I observe that whenever I set keras.backend.learning_phase():1, the model train/test accuracy hardly increase above 10%. In contrast, if the learning phase is not set i.e., the feed dictionary is defined as:

feed_dict= {x:X_train[indices[start:end]], y:Y_train[indices[start:end]]}

Then as expected, the model accuracy keeps in increasing with epochs in a standard way.

I would appreciate if someone clarifies whether the use of learning phase is not necessary or if something else is wrong. Keras 2.0 documentation seems to suggest using learning phase with dropout and batch_norm layers.


Viewing all articles
Browse latest Browse all 14389

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>