c++ - 有没有办法在 C++ 中保存冻结的张量流图?
问题描述
我知道您可以使用 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));
推荐阅读
- php - cron 运行时 Symfony 命令未执行
- javascript - JavaScript 闭包函数
- php - 如何从排队的作业中启动工匠命令,然后在使用数据库驱动程序执行后删除作业
- java - 我可以在一个缓存中缓存多个表,还是需要为每个表维护单独的缓存?
- python - 使用 Openpyxl 在现有工作表中从特定列和行开始写入现有 excel 文件
- laravel - 如何在主管中动态更改 numprocs
- java - 使用 JPA Criteria API 将子查询 SELECT 作为字段
- c++ - 就地合并向量的 N 段 C++
- angular - 在`npm update`之后得到`error TS2304: Cannot find name 'module'`
- php - 卷曲到 yii1.1 动作返回空结果