i have saved my model using script in python but when i want to use it in ibtorch c++, for different inputs i always get the same output like [0.4816 0.5184].
SOLVED!
net = Net()
net.load_state_dict(torch.load("Path/weights.pth"))
net.eval()
input_random = torch.rand((1, 3, 224, 224))
output = net(input_tensor)
print(output)
traced_net = torch.jit.trace(Net(), input_random)
traced_net.save("Saving_Path/jit.pt")
my problem was putting
Net()
instead of
net
inside the
torch.jit.trace()
so the true code must be like:
traced_net = torch.jit.trace(net, input_random)