我知道您可以使用 Python 将模型保存到检查点或 SavedModel 中。我想知道是否有办法使用 C++ 保存从 FreezeSavedModel C++ 函数返回的 GraphDef。谢谢!
函数 FreezeSavedModel 返回一个GraphDef -Object。您可以使用WriteBinaryProto或WriteTextProto保存此对象
//BinaryProto
const string binary_file = io::JoinPath(testing::TmpDir(), "binary_graph.pb");
TF_ASSERT_OK(WriteBinaryProto(Env::Default(), binary_file, graph_def));
//Textproto
const string text_file = io::JoinPath(testing::TmpDir(), "text_graph.pbtxt");
TF_ASSERT_OK(WriteTextProto(Env::Default(), text_file, graph_def));
您可以在file_utils_test.cc 中找到示例
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句