Putting custom dropout in .eval mode


(Rahul Deora) #1

I am writting a custom version of dropblock and want to switch it off in evaluation mode by calling model.eval(), however I have no clue how to go about this. I tried looking at functional dropout but it is not defined there. How can this be done?


#2

You could use the self.training flag in your custom module to switch between the different behaviors:

  • apply your mask and scale the activations if self.training
  • disable the mask and just forward the activations if self.training == False

Let me know, if that works for you.