Satinder Pal Singh
Satinder Pal Singh

Reputation: 67

Can someone help explain the use of keras.backend.learning_phase_scope(1)?

Need help as I am new to Keras and was reading on dropout and how using dropout can have an impact on loss calculation during training and validation phase. This is because dropout is only present at training time and not validation time, so comparing two losses can be misleading.

Question is

  1. The use of learning_phase_scope(1)
  2. how does it impact validation
  3. What steps to do to correct for testing loss when dropout is used?

Upvotes: 1

Views: 158

Answers (1)

Natthaphon Hongcharoen
Natthaphon Hongcharoen

Reputation: 2440

It's not only Dropout but BatchNormalization as well that need to be changed or it'll affect validation performance.

If you use keras and just want to get validation loss (and or accuracy or other metrics) then you better use model.evaluate() or add validation_data while model.fit and don't do anything with learning_phase_scope.

The learning_phase_scope(1) means it's for training, 0 is for predict/validate.

Personally I use learning_phase_scope only when I want to train something that not end with simply model.fit (visualize CNN filter) but only once so far in past 3 years.

Upvotes: 2

Related Questions