I have trained my model and saved it to use in C++ environment. When i am trying to predict the results in C++ it is showing different results in comparison to my pytorch model. I have used the exact as shown in pytorch tutorial. This is my code for C++.
#include <torch/script.h>
#include <memory>
#include <iostream>
int main(int argc, const char* argv[])
{
 if (argc != 2) {
    std::cerr << "usage: main <path-to-exported-script-module>\n";
    return -1;
  }

  try {
    // Deserialize the ScriptModule from a file using torch::jit::load().
    torch::jit::script::Module module;
    module = torch::jit::load("/home/sunny/neural/diffusion2.pt");
    // Create a vector of inputs.
    double x;
    std::cout<<"Please enter the value of x ";
    std::cin>>x;
    double t;
    std::cout<<"Please enter the value of t ";
    std::cin>>t;
    
    std::vector<torch::jit::IValue> inputs;
    inputs.push_back(torch::tensor({{x,t}}));
    // Execute the model and turn its output into a tensor.
    torch::Tensor output = module.forward((inputs)).toTensor();

    std::cout << "u(x,t) = " << output << std::endl;
    
  }
  catch (const c10::Error& e) {
    std::cerr << "error loading the model\n";
    return -1;
  }

}

One more thing. I tried many times to save my model to use in C++ and it show different results every time . Do anyone know what is going wrong?