Set different behaior between train and eval

hi

I need a flag to determine whether my model is training or evaluation. in order to define different behavior for hybridmodule

In Pyotrch, there is a self.training flag, I wonder is there a counterpart in mxnet?

In symbolic programming using the Module API, you can set the is_train argument to True or False in forward propagation. for more information see:
https://mxnet.incubator.apache.org/api/python/docs/api/module/index.html#mxnet.module.BaseModule.forward

Thans @shababqcd

In fact, I’m using the hybrid_forward. I found another solution.

Because the Dropout layer has different behaviro and training and test, so I found a tutorial about Accessing is_training_status

with autograd.predict_mode():
    print(autograd.is_training())

with autograd.train_mode():
    print(autograd.is_training())

so the autograd.is_training() is my desired flag.

2 Likes

Thanks @Alpha for posting your solution. Here is a link of the latest tutorial on autograd: http://d2l.ai/chapter_crashcourse/autograd.html#training-mode-and-prediction-mode

1 Like