如何通过 CLI 在 Caffe 中生成预测标签?
How to generate the predicted labels in Caffe through the CLI?
我使用 Caffe 训练了一个神经网络模型:
/home/f/caffe-master/build/tools/caffe train -solver=/media/my_solver.prototxt
然后我在验证集上对学习模型进行了评分:
/home/f/caffe-master/build/tools/caffe test -model=/media/my_train_test.prototxt
-weights model.caffemodel -iterations 100
但是如何在Caffe中获取训练好的神经网络模型预测的标签呢?
我知道我可以为此目的使用 Python 或 Matlab 绑定,但我很想知道我们是否可以直接通过命令行界面在 Caffe 中获取预测标签。
official Caffe's tutorial on interfaces里面好像没有提到,看caffe
的帮助也没用:
> f@f-VirtualBox:~/caffe/caffe-master/build/tools$ ./caffe
caffe: command line brew
usage: caffe <command> <args>
commands:
train train or finetune a model
test score a model
device_query show GPU diagnostic information
time benchmark model execution time
Flags from /home/f/caffe-master/tools/caffe.cpp:
-gpu (Run in GPU mode on given device ID.) type: int32 default: -1
-iterations (The number of iterations to run.) type: int32 default: 50
-model (The model definition protocol buffer text file..) type: string
default: ""
-snapshot (Optional; the snapshot solver state to resume training.)
type: string default: ""
-solver (The solver definition protocol buffer text file.) type: string
default: ""
-weights (Optional; the pretrained weights to initialize finetuning. Cannot
be set simultaneously with snapshot.) type: string default: ""
如果您不想通过 Python,您可以添加一个 HDF5_OUTPUT 层:它会将预测输出保存在 HDF5 文件中。
否则,如果您想进入代码,您可以在 https://github.com/BVLC/caffe/blob/master/src/caffe/layers/accuracy_layer.cpp#L74
左右打印或保存 bottom_data_vector[k].second
我使用 Caffe 训练了一个神经网络模型:
/home/f/caffe-master/build/tools/caffe train -solver=/media/my_solver.prototxt
然后我在验证集上对学习模型进行了评分:
/home/f/caffe-master/build/tools/caffe test -model=/media/my_train_test.prototxt
-weights model.caffemodel -iterations 100
但是如何在Caffe中获取训练好的神经网络模型预测的标签呢?
我知道我可以为此目的使用 Python 或 Matlab 绑定,但我很想知道我们是否可以直接通过命令行界面在 Caffe 中获取预测标签。
official Caffe's tutorial on interfaces里面好像没有提到,看caffe
的帮助也没用:
> f@f-VirtualBox:~/caffe/caffe-master/build/tools$ ./caffe
caffe: command line brew
usage: caffe <command> <args>
commands:
train train or finetune a model
test score a model
device_query show GPU diagnostic information
time benchmark model execution time
Flags from /home/f/caffe-master/tools/caffe.cpp:
-gpu (Run in GPU mode on given device ID.) type: int32 default: -1
-iterations (The number of iterations to run.) type: int32 default: 50
-model (The model definition protocol buffer text file..) type: string
default: ""
-snapshot (Optional; the snapshot solver state to resume training.)
type: string default: ""
-solver (The solver definition protocol buffer text file.) type: string
default: ""
-weights (Optional; the pretrained weights to initialize finetuning. Cannot
be set simultaneously with snapshot.) type: string default: ""
如果您不想通过 Python,您可以添加一个 HDF5_OUTPUT 层:它会将预测输出保存在 HDF5 文件中。
否则,如果您想进入代码,您可以在 https://github.com/BVLC/caffe/blob/master/src/caffe/layers/accuracy_layer.cpp#L74
左右打印或保存bottom_data_vector[k].second