正常训练的caffe模型位于.caffemodel
扩展名中,实际上它们是binary protobuf
格式。
知道如何将hdf5
格式的caffe模型加载到c ++中的caffe net中吗?
我有一个用hdf5
格式的python caffe训练的模型。
我的应用程序是使用caffe c ++版本的c ++,我更喜欢使用c ++而不是python。
如何将以hdf5格式的caffe训练模型中的模型读取到c ++ caffe net?
我知道caffe里面有hdf5data层。 有没有示例程序?
修改
我使用了CopyTrainedLayersFromHDF5()api并遇到了以下运行时错误。
HDF5-DIAG: Error detected in HDF5 (1.8.11) thread 140737353775552:
#000: ../../../src/H5G.c line 463 in H5Gopen2(): unable to open group
major: Symbol table
minor: Can't open object
#001: ../../../src/H5Gint.c line 320 in H5G__open_name(): group not found
major: Symbol table
minor: Object not found
#002: ../../../src/H5Gloc.c line 430 in H5G_loc_find(): can't find object
major: Symbol table
minor: Object not found
#003: ../../../src/H5Gtraverse.c line 861 in H5G_traverse(): internal path traversal failed
major: Symbol table
minor: Object not found
#004: ../../../src/H5Gtraverse.c line 641 in H5G_traverse_real(): traversal operator failed
major: Symbol table
minor: Callback failed
#005: ../../../src/H5Gloc.c line 385 in H5G_loc_find_cb(): object 'data' doesn't exist
major: Symbol table
minor: Object not found
F0220 15:32:14.272573 24576 net.cpp:811] Check failed: data_hid >= 0 (-1 vs. 0) Error reading weights from model_800000.h5
*** Check failure stack trace: ***
@ 0x7ffff64afdcd google::LogMessage::Fail()
@ 0x7ffff64b1d08 google::LogMessage::SendToLog()
@ 0x7ffff64af963 google::LogMessage::Flush()
@ 0x7ffff64b263e google::LogMessageFatal::~LogMessageFatal()
@ 0x7ffff691c3a3 caffe::Net<>::CopyTrainedLayersFromHDF5()
@ 0x40828d ExtractFeature::ExtractFeature()
@ 0x40ce78 main
@ 0x7ffff5bf8f45 __libc_start_main
@ 0x4080c9 (unknown)
Program received signal SIGABRT, Aborted.
0x00007ffff5c0dc37 in __GI_raise (sig=sig@entry=6)
at ../nptl/sysdeps/unix/sysv/linux/raise.c:56
56 ../nptl/sysdeps/unix/sysv/linux/raise.c: No such file or directory.
(gdb) cd
[17]+ Stopped gdb ./endtoendlib
编辑1:
>>h5ls model_800000.h5 command gave me
conv1 Group
conv2 Group
forget_gate Dataset {1, 250, 1, 1274}
inception_3a Group
inception_3b Group
inception_4a Group
inception_4b Group
inception_4c Group
inception_4d Group
inception_4e Group
inception_5a Group
inception_5b Group
input_gate Dataset {1, 250, 1, 1274}
input_value Dataset {1, 250, 1, 1274}
ip_bbox_unscaled0.p0 Dataset {4, 250}
ip_bbox_unscaled0.p1 Dataset {4}
ip_bbox_unscaled1.p0 Dataset {4, 250}
ip_bbox_unscaled1.p1 Dataset {4}
ip_bbox_unscaled2.p0 Dataset {4, 250}
ip_bbox_unscaled2.p1 Dataset {4}
ip_bbox_unscaled3.p0 Dataset {4, 250}
ip_bbox_unscaled3.p1 Dataset {4}
ip_bbox_unscaled4.p0 Dataset {4, 250}
ip_bbox_unscaled4.p1 Dataset {4}
ip_conf0.p0 Dataset {2, 250}
ip_conf0.p1 Dataset {2}
ip_conf1.p0 Dataset {2, 250}
ip_conf1.p1 Dataset {2}
ip_conf2.p0 Dataset {2, 250}
ip_conf2.p1 Dataset {2}
ip_conf3.p0 Dataset {2, 250}
ip_conf3.p1 Dataset {2}
ip_conf4.p0 Dataset {2, 250}
ip_conf4.p1 Dataset {2}
output_gate Dataset {1, 250, 1, 1274}
post_fc7_conv.p0 Dataset {1024, 1024, 1, 1}
post_fc7_conv.p1 Dataset {1024}
答案 0 :(得分:1)
您是否考虑过net
对象方法void CopyTrainedLayersFromHDF5(const string trained_filename);
?它看起来像你正在寻找的。 p>
至于"HDF5Data"
图层:你在这里混淆了两件事。您拥有的hdf5文件存储了网络的训练参数。相比之下,"HDF5Data"
图层存储用于训练网络的训练示例。