TensorFlow无法读取自己保存的pb模型
六步狼 2016-12-21 01:03:23 想把AlexNet迁移到TensorFlow 的android项目上,于是把http://www.cs.toronto.edu/~guerzhoy/tf_alexnet/ 这个网上的myalexnet保存成pb文件,保存在python上测试该pb是可识别物体的,但是移植到 android 端上就会闪退,报如下错误:
TensorflowAndroid/jni/jni_utils.cc:116 Check failed: message->ParseFromZeroCopyStream(&lis)
jni_utils.cc读取pb代码如下:
AAsset* asset = AAssetManager_open(asset_manager,
asset_filename,
AASSET_MODE_STREAMING);
CHECK_NOTNULL(asset);
off_t start;
off_t length;
const int fd = AAsset_openFileDescriptor(asset, &start, &length);
if (fd >= 0) {
// If it has a file descriptor that means it can be memmapped directly
// from the APK.
VLOG(0) << "Opening asset " << asset_filename
<< " from disk with zero-copy.";
google::protobuf::io::FileInputStream is(fd);
google::protobuf::io::LimitingInputStream lis(&is, start + length);
lis.Skip(start);
CHECK(message->ParseFromZeroCopyStream(&lis));
is.Close();
}
也就是说无法从这个pb文件读取数据进来,还望请教各位是如何在Tensorflow替换自己的pb模型的?