I try to make predictions for a 4-class classification project in C++ side using libtorch 1.4. However, I cannot obtain same predictions compared to Python side. Firstly, I obtain same input tensor values just before prediction. When I compare the output tensor values, I noticed that they are different. You can find those values in that picture:
Left side includes Python output tensor values and the prediction results for each input picture.
Right side includes C++ output tensor values and the prediction results for each input picture.
Could you offer a solution to obtain same output tensor values and prediction results?
Did you make sure to set the model to evaluation mode via model.eval() before executing the forward pass?
Also, I assume you’ve checked the inputs already or are you using any (random) preprocessing steps?
This operation changes only the first channel and does not change other channels. For this reason, in fact, input tensor values are different. I applied normalization directly on tensor values writing this code: