How to load state_dict to Module in PyTorch C++

Hey there,

i have a model trained in Python/PyTorch and saved it via "torch.save({‘model’, model.state_dict()}). The task is to load this “.pth.tar”-file into a C++/PyTorch module and apply it to the same architecture.
Is there a similar method to the Python/PyTorch mehtod "model.load_state_dict(torch.load(“model.pth.tar”)) in C++/PyTorch?

Thanks a lot!

By the way, does a serializated ScriptModule (module.save(“model.pt”)) also saves the state of the module or only the architecture itself?

Thanks again!

So the answer here

is yes. Does that also solve the need for loading the state dict?
I cannot praise the export to c++ tutorial enough.

Best regards

Thomas