Keunhoi_An:

Oh, you mean that I should input same input like torch.ones first and then call model.eval() even I’ve already loaded .pt file in c++? Without that, is it not possible to initialize the model in c++?


Using a constant input would remove the possibility of a different preprocessing or loading logic between your codes. It’s not needed to initialize the model.
Did you call model.eval() using your model as well? This would be necessary to compare the outputs, as e.g. dropout layers might be used in the models.



 Keunhoi_An:

After test your advice, it output the almost same result result with torch.ones and standard ResNet…


Could you use the same workflow (contant inputs and model.eval()) using your model and check the outputs again?