tensorflow2.0和之前版本读取模型的接口变化
2024-10-21 23:11:05
tensorflow2.0 c++加载模型可以用接口LoadSavedModel:
SessionOptions opts;
tensorflow::RunOptions run_options;
opts.config.mutable_gpu_options()->set_visible_device_list({m_deviceList.c_str()});
Status status_create = LoadSavedModel(m_modelPath, {tensorflow::kSavedModelTagServe}, &m_bundle);
if(!status_create.ok()){
return false;
}
tesorflow2.0之前的接口为ReadBinaryProto;
GraphDef graph_def;
Status status_load = ReadBinaryProto(Env::Default(), fullPath, &graph_def);
if (!status_load.ok()) {
return false;
}
模型也可以以字节流的方式输入模型:
GraphDef graph_def;
if (!graph_def.ParseFromArray(data_buff, readLen)) {
delete[]data_buff;
return FALSE;
}
SessionOptions opts;
opts.config.mutable_gpu_options()->set_allow_growth(true);
opts.config.mutable_gpu_options()->set_per_process_gpu_memory_fraction(0.5);
opts.config.mutable_gpu_options()->set_visible_device_list({"1,2,3,0"});
std::shared_ptr<tensorflow::Session> session_prt(tensorflow::NewSession(opts));
m_session_prt = session_prt;
最新文章
- 玩转SQL Server复制回路の变更数据类型、未分区表转为分区表
- synthesize 与dynamic的区别
- Spring Security
- hello word
- java_easyui体系之DataGrid(1)[转]
- bzoj 1228 [SDOI2009]E&;D(sg函数,找规律)
- A basic Windows service in C++ (CppWindowsService)
- linux下用tar命令将当前目录下文件按子目录压缩归档
- Android系统移植(一)-让android系统在目标平台上运行起来
- java_web学习(十) 显示mysql中的数据
- 过滤Java中特殊字符
- 微信小程序发布
- asp.net core上使用redis探索(1)
- mysql自增长主键,删除数据后,将主键顺序重新排序
- Linux系统时间同步方法小结
- java算法----排序----(3)冒泡排序
- ARIMA模型识别、计算p、q值
- mysql windows开启客户端连接权限
- uva 11354 Bond
- js三目学习