How to run inference on a trained model

After building and training a regression model, I saved then loaded the model and I am now trying to run inferences on the loaded model in order to get the loss value and calculate other metrics.
Is there anything similar to Keras’:

model.evaluate(x_val, y_val,verbose=1)



Thank you.

You should call model.eval() to set the model to evaluation mode, which will change the behavior of some modules (e.g. batchnorm layers will use their running stats and dropout will be disabled) and can then directly pass your test data:

out = model(test_tensor)

Thanks for the quick reply!

I already tried that, but surprisingly, didn’t get the same output as the one I got when I first ran the training and testing loop… I thought there must be others ways to do it.
I’ll take a closer look at the code… there should be something missing.