Hi, I want to use my pretrained model(which is trained onpPytorch) in my C++ project. I have saved my network in Python and loaded in C++ using jit.
//Python
traced_script_module = torch.jit.trace(model, input)
traced_script_module.save("model.pt")
//C++
torch::jit::script::Module model =torch::jit::load(file_name);


I am passing CUDAFloatTensor as an input. I am supposed to have three outputs from my model.
auto outputs = model.forward({ input });
auto heatmap= outputs.toTuple()->elements()[0].toTensor(); 
auto bbox = outputs.toTuple()->elements()[1].toTensor();
auto scan_rec= outputs.toTuple()->elements()[2].toTensor();

I realized forward pass doesn’t always give correct results. Sometimes it gives answer below.(which is the right answer I checked on Python and outputs on there are always consistent)
first three elements of bbox : 0.4311, 0.4620, 0.3915
But most of the times I get values like this in each three output and I am having exception when I am trying to use my outputs.
first three elements of bbox : = 9.3593e-36, 3.9978e+07,-5.3179e+37
Which is really weird. I am assuming there is some kind of overflow going on. I don’t want to train any network in C++. I just want to use my pretrained model as a deterministic function. I also set these in any case before calling forward pass but it didn’t help. I have no idea what is going on.
torch::manual_seed(0);
torch::NoGradGuard no_grad;

Environment:
Windows 10
CUDA 10.1
Visual Studio 2019
Libtorch 1.5 Nightly Release