Shortcuts

Template Function torch::load(Value&, LoadFromArgs&&…)

Function Documentation

template<typename Value, typename ...LoadFromArgs>
void torch::load(Value &value, LoadFromArgs&&... args)

Deserializes the given value.

There must be an overload of operator>> between serialize::InputArchive and Value for this method to be well-formed. Currently, such an overload is provided for (subclasses of):

To perform the serialization, a serialize::InputArchive is constructed, and all arguments after the value are forwarded to its load_from method. For example, you can pass a filename, or an istream.

torch::nn::Linear model(3, 4);
torch::load(model, "model.pt");

torch::optim::SGD sgd(model->parameters(), 0.9); // 0.9 is learning rate
std::istringstream stream("...");
torch::load(sgd, stream);

auto tensor = torch::ones({3, 4});
torch::load(tensor, "my_tensor.pt");

Docs

Access comprehensive developer documentation for PyTorch

View Docs

Tutorials

Get in-depth tutorials for beginners and advanced developers

View Tutorials

Resources

Find development resources and get your questions answered

View Resources