caffe训练好模型的特征提取(fc7,最后一层全连接层)

参考langb014
参考caffe官网


  1. 1.生成临时文件夹

  2. $ mkdir examples/_temp 


  3. 2、我们为三张图片添加一个文件列表 

  4. $ find `pwd`/examples/images -type f -exec echo {} \; > examples/_temp/temp.txt 

  5. 3、将使用 imagedatalayer 预计标签之后的每一个文件名,所以让我们添加一个 0 到每一行  
  6. 的末尾 

  7. $ sed "s/$/ 0/" examples/_temp/temp.txt > examples/_temp/file_list.txt

  8. 4、从 ILSVRC dataset 中下载均值图像数据库 

  9. $ ./data/ilsvrc12/get_ilsvrc_aux.sh 

  10. 5、使用其中的 data/ilsvrc212/imagenet_mean.binaryproto 去定义网络结构。将定义结构的文件 cope 到我们的临时文件夹。 

  11. $ cp examples/feature_extraction/imagenet_val.prototxt examples/_temp 

  12. 6、进入 imagenet_val.prototxt 更改路径。更改其中$CAFFE的地方(这里我没有做任何修改。) 

  13. 7、提取特征  (权重?)

  14. $  (GPU模式并且将细节输出到txt文件中,文件在caffe-master目录下)

  15. Usage: extract_features  pretrained_net_param  feature_extraction_proto_file  extract_feature_blob_name1[,name2,...]  save_feature_dataset_name1[,name2,...]  num_mini_batches  db_type  [CPU/GPU] [DEVICE_ID=0]
    Note: you can extract multiple features in one pass by specifying multiple feature blob names and dataset names seperated by ','. The names cannot contain white space characters and the number of blobs and datasets must be equal.

  16. 8、出现错误“Check failed: status.ok() Failed to open leveldb examples/_temp/features”  (一般是在每次运行没删除文件夹之后)

  17. $ rm -rf examples/_temp/features/ 

  18. 再运行一次基本就可以了。

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 3
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值