Caffe:train_test.prototxt 和 deploy.prototxt 有什么区别?
Caffe: what's the difference between train_test.prototxt and deploy.prototxt?
在 GoogleNet 等相关模型中
https://github.com/BVLC/caffe/tree/master/models/bvlc_googlenet
我们可以看到两个描述网络的 .prototxt 文件,它们之间的区别是什么?
我的关键问题是,在python界面中,为什么我只能使用前一个?也就是说:
model_def = caffe_root + 'models/bvlc_googlenet/deploy.prototxt'
model_weights = caffe_root + 'models/bvlc_googlenet/bvlc_googlenet.caffemodel'
net = caffe.Net(model_def,model_weights,caffe.TEST)
此代码在以下情况下运行正确:
model_def = caffe_root + 'models/bvlc_googlenet/train_val.prototxt'
model_weights = caffe_root + 'models/bvlc_googlenet/bvlc_googlenet.caffemodel'
net = caffe.Net(model_def,model_weights,caffe.TEST)
这不是。并给出错误信息:
layer {
name: "inception_4e/relu_5x5_reduce"
type: "ReLU"
bottom: "inception_4e/5x5_reduce"
top: "inception_4e/5x5_reduce"
}
layer {
I0805 10:15:13.698256 30930 layer_factory.hpp:77] Creating layer data
I0805 10:15:13.698444 30930 net.cpp:100] Creating Layer data
I0805 10:15:13.698465 30930 net.cpp:408] data -> data
I0805 10:15:13.698514 30930 net.cpp:408] data -> label
F0805 10:15:13.699956 671 db_lmdb.hpp:15] Check failed: mdb_status == 0 (2 vs. 0) No such file or directory
*** Check failure stack trace: ***
为什么?有什么区别?
train_val.prototxt
用于训练,而deploy.prototxt
用于推理。
train_val.prototxt
有训练数据所在位置的信息。在您的情况下,它包含包含训练数据的 lmdb 文件的路径。
deploy.prototxt
包含有关输入大小的信息,但不包含有关输入本身的任何信息。因此,您可以将具有该尺寸的任何图像作为输入传递给它并进行推理。
当您加载 train_val.prototxt
时,它会查找其中提到的训练数据文件。您遇到错误,因为它无法找到它。
提示:在进行推理时,最好使用deploy.prototxt
。
在 GoogleNet 等相关模型中 https://github.com/BVLC/caffe/tree/master/models/bvlc_googlenet
我们可以看到两个描述网络的 .prototxt 文件,它们之间的区别是什么?
我的关键问题是,在python界面中,为什么我只能使用前一个?也就是说:
model_def = caffe_root + 'models/bvlc_googlenet/deploy.prototxt'
model_weights = caffe_root + 'models/bvlc_googlenet/bvlc_googlenet.caffemodel'
net = caffe.Net(model_def,model_weights,caffe.TEST)
此代码在以下情况下运行正确:
model_def = caffe_root + 'models/bvlc_googlenet/train_val.prototxt'
model_weights = caffe_root + 'models/bvlc_googlenet/bvlc_googlenet.caffemodel'
net = caffe.Net(model_def,model_weights,caffe.TEST)
这不是。并给出错误信息:
layer {
name: "inception_4e/relu_5x5_reduce"
type: "ReLU"
bottom: "inception_4e/5x5_reduce"
top: "inception_4e/5x5_reduce"
}
layer {
I0805 10:15:13.698256 30930 layer_factory.hpp:77] Creating layer data
I0805 10:15:13.698444 30930 net.cpp:100] Creating Layer data
I0805 10:15:13.698465 30930 net.cpp:408] data -> data
I0805 10:15:13.698514 30930 net.cpp:408] data -> label
F0805 10:15:13.699956 671 db_lmdb.hpp:15] Check failed: mdb_status == 0 (2 vs. 0) No such file or directory
*** Check failure stack trace: ***
为什么?有什么区别?
train_val.prototxt
用于训练,而deploy.prototxt
用于推理。
train_val.prototxt
有训练数据所在位置的信息。在您的情况下,它包含包含训练数据的 lmdb 文件的路径。
deploy.prototxt
包含有关输入大小的信息,但不包含有关输入本身的任何信息。因此,您可以将具有该尺寸的任何图像作为输入传递给它并进行推理。
当您加载 train_val.prototxt
时,它会查找其中提到的训练数据文件。您遇到错误,因为它无法找到它。
提示:在进行推理时,最好使用deploy.prototxt
。