Template Function torch::load(Value&, LoadFromArgs&&…)#
Defined in File serialize.h
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>>betweenserialize::InputArchiveandValuefor this method to be well-formed. Currently, such an overload is provided for (subclasses of):torch::Tensor
To perform the serialization, a
serialize::InputArchiveis constructed, and all arguments after thevalueare forwarded to itsload_frommethod. For example, you can pass a filename, or anistream.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");