Different output before&after train mode changed

Hi guys, I’m running such code:

                so = self.classifiers[y_predictions[0]].model(inputs)
                self.classifiers[y_predictions[0]].model.train(True)
                soo = self.classifiers[y_predictions[0]].model(inputs)
                self.classifiers[y_predictions[0]].model.train(False)
                sooo = self.classifiers[y_predictions[0]].model(inputs)

self.classifiers[y_predictions[0]].model is the original ResNet18 appended by PyTorch and is used for bin-classification.

I’m confused why so, soo and sooo have different value shown above? Thanks in advance.

While training mode, there is some tricky changes such as dropout, batch norm. etc… Hence, giving different outputs is so normal. You can read this post i found.