环境:windows 7+matlab2016a+vs2013

caffe下载地址:https://github.com/BVLC/caffe/tree/windows

1 进入caffe-windows的windows文件夹,Copy .\windows\CommonSettings.props.example to .\windows\CommonSettings.props

2 打开caffe工程,编辑CommonSettings.props文件,以下是cpu版本设置

<CpuOnlyBuild>true</CpuOnlyBuild>
        <UseCuDNN>false</UseCuDNN>
        <CudaVersion>7.5</CudaVersion>
        <PythonSupport>false</PythonSupport>
        <MatlabSupport>true</MatlabSupport>
        <CudaDependencies></CudaDependencies>

<PropertyGroup Condition="'$(MatlabSupport)'=='true'">
        <MatlabDir>C:\Program Files\MATLAB\R2016a</MatlabDir>
        <LibraryPath>$(MatlabDir)\extern\lib\win64\microsoft;$(LibraryPath)</LibraryPath>
        <IncludePath>$(MatlabDir)\extern\include;$(IncludePath)</IncludePath>
    </PropertyGroup>

3  选择matcaffe项目,点击编译(会自动去下载第三方库),在Build\x64\Release会生成相应的文件

4 将上面Build\x64\Release绝对路径加入到系统环境path变量中,同时将Build\x64\Release\matcaffe加入到matlab路径中。

5 重新启动matlab,调用caffe.reset_all(),则说明ok。

>> caffe.reset_all();
Cleared 0 solvers and 0 stand-alone nets
>>

python使用

下载安装anaconda

安装protobuf:在命令行输入:pip install protobuf

使用spyder,并且设置Python路径

import caffe

caffe在matlab中使用:

function train()
solver_def_file = 'model/lenet_solver.prototxt';
caffe.set_mode_cpu();
caffe.reset_all();
solver = caffe.Solver(solver_def_file);
% solver.solve();%一次性迭代close all;
hold on%画图用的
iter_ = solver.iter();
while iter_<10000solver.step(1);%一步一步迭代iter_ = solver.iter();    loss=solver.net.blobs('loss').get_data();%取训练集的loss  if iter_==1loss_init = loss;elsey_l=[loss_init loss];x_l=[iter_-1, iter_];     plot(x_l, y_l, 'r-');drawnowloss_init = loss;endif mod(iter_, 100) == 0accuracy=solver.test_nets.blobs('accuracy').get_data();%取验证集的accuracy       if iter_/100 == 1accuracy_init = accuracy;else x_l=[iter_-100, iter_];y_a=[accuracy_init accuracy];plot(x_l, y_a,'g-');drawnowaccuracy_init=accuracy;endend
end

测试

function test()
net = init_net();
im_data = 255-caffe.io.load_image('image/00082.png');
res = net.forward({im_data});
[~, idx ]= max(res{1});
disp(idx-1);function net = init_net()
caffe.set_mode_cpu();
caffe.reset_all();
deploy = 'model/lenet_deploy.prototxt';
caffe_model = 'snapshot/lenet_iter_10000.caffemodel';
net = caffe.Net(deploy, caffe_model, 'test');

微调

function retrain()
caffe.set_mode_cpu();
caffe.reset_all();
caffe_model = 'snapshot/lenet_iter_10000.caffemodel';
solver = caffe.Solver('model/lenet_solver.prototxt');
solver.net.copy_from(caffe_model);
% solver.solve();close all;
hold on%画图用的
iter_ = solver.iter();
while iter_<10000solver.step(1);iter_ = solver.iter();    loss=solver.net.blobs('loss').get_data();%取训练集的loss  if iter_==1loss_init = loss;elsey_l=[loss_init loss];x_l=[iter_-1, iter_];     plot(x_l, y_l, 'r-');drawnowloss_init = loss;endif mod(iter_, 100) == 0accuracy=solver.test_nets.blobs('accuracy').get_data();%取验证集的accuracy       if iter_/100 == 1accuracy_init = accuracy;else x_l=[iter_-100, iter_];y_a=[accuracy_init accuracy];plot(x_l, y_a,'g-');drawnowaccuracy_init=accuracy;endend
end

转载于:https://www.cnblogs.com/linyuanzhou/p/5913505.html

windows配置caffe及matlab/python接口编译和调用(cpu/gpu)相关推荐

  1. c++调用python接口打包_C++ 调用Python脚本

    本人环境: Windows10: python3.7.4: visual studio 2019: 安装python,opencv(如果用到的话),以及将二者目录添加到vs中的包含目录和库目录就不再说 ...

  2. js调用python接口_JavaScript如何调用Python后端服务

    欢迎关注[无量测试之道]公众号,回复[领取资源], Python编程学习资源干货. Python+Appium框架APP的UI自动化. Python+Selenium框架Web的UI自动化. Pyth ...

  3. Windows 10 Visual Studio 2015 配置 Caffe

    笔记本是双显卡,读研的时候成功的在Ubuntu下配置好了一次Caffe,并且完成了深度学习的实验,前不久因为一个小的问题,导致NVIDIA驱动出了问题,以后再也没有在Ubuntu下成功配置好Caffe ...

  4. python caffe框架_ubuntu14.04 intel集成显卡配置caffe框架(用cpu跑)+pycharm自带python导入caffe框架...

    用cpu跑,不用安装CUDA. 1.安装依赖库 安装[build-essentials] 安装开发所需要的一些基本的包, sudo apt-get install build-essential BL ...

  5. Python程序编译为动态库pyd或so (适用于Windows和Linux)

    Welcome to My Blog 文章唯一地址:https://blog.csdn.net/REAL_liudebai/article/details/125126432 问题:   1)Pyth ...

  6. Windows7下Caffe的应用---在Win7下使用VS2015、Camke、Anaconda3配置Caffe CPU版本

    前言 1.之前一直在Linux使用Caffe做机器学习的相关的项目,相对于Linux,在Windows配置Caffe相对麻烦一些,我这里使用Cmake gui版本,适合新手操作. 2.我配置的环境是w ...

  7. Caffe和MATLAB

    这篇总结是对前面的一个补课吧,caffe配matlab,包括ubuntu下面matlab2016b的破解安装,其实我这是想跑一个demo看看效果而已.OK先安装matlab 安装matlab2016b ...

  8. python接口返回状态码,Python脚本接口返回正常,状态码405

    最近些Python接口脚本时调用post接口时返回结果正常,状态码却不对. ,代码如下: 此接口完成的功能为新增一个角色,角色添加成功返回角色的id信息,但是状态码为405,405是Method No ...

  9. ubuntu14.04下安装cudnn5.1.3,opencv3.0,编译caffe及配置matlab和python接口过程记录

    已有条件: ubuntu14.04+cuda7.5+anaconda2(即python2.7)+matlabR2014a 上述已经装好了,开始搭建caffe环境. 1. 装cudnn5.1.3,参照: ...

  10. 在win10中安装caffe并配置MATLAB和Python接口(支持GPU加速)

    笔记本电脑配置(14年的老机器)CPU i54200 显卡:GTX850m 1.软件准备: vs2013 cuda8.0(官网下载,查看显卡是否支持cuda),cudnn v5.0(支持cuda8.0 ...

最新文章

  1. jQuery日期选择器插件date-input
  2. harris角点检测与ncc匹配
  3. zookeeper 运维管理
  4. 0125互联网新闻 | 抖音海外版 TikTok 12月新增7500万;少儿编程平台“编程猫”计划在2 年内IPO...
  5. matlab对图像进行均值滤波_用K均值进行图像分割
  6. TCP对应的应用层协议之FTP /SMTP / HTTP
  7. Real to Int
  8. Java基础(三)对象与类
  9. mysql压力写入测试_mysql压力测试工具
  10. 一个做法是给一个解决方案一个ComDLL的目录
  11. (转)Java任务调度框架Quartz入门教程指南(二) 使用job、trigger、schedule调用定时任务...
  12. 浅谈android的am命令
  13. Jquery和JS获取ul中li标签
  14. MVC数据验证Model Validation
  15. 关于调整我省高等教育自学考试计算机及应用等五个专业计划的通知,关于2008年我省高等教育自学考试计算机及应用等五个专业考生执行专业考试计划有关问题的通知...
  16. Linux自学:常用删除命令(rm)使用方法
  17. 基于JDK1.8的JVM 内存结构【JVM篇三】
  18. linux导航改端口波特率,各大导航端口速率修改方法
  19. Android 12 灭屏流程(一) Power键灭屏
  20. 超实数与单子(Monad)

热门文章

  1. 【转】从简单的 F# 表达式构建并发应用程序
  2. 【炼丹技巧】惊了,掌握了这个炼丹技巧的我开始突飞猛进
  3. [CLS]预训练语言模型的前世今生[SEP]萌芽时代[SEP]
  4. 【分词】从why到how的中文分词详解,从算法原理到开源工具
  5. 学术分享 | 没有导师的指导,研究生如何阅读文献、提出创见、写论文?
  6. ②⓪②⓪ → ②⓪②①
  7. 每日算法系列【LeetCode 121】买卖股票的最佳时机
  8. 论文精读—XGBoost paper
  9. 李宏毅机器学习——深度学习反向传播算法
  10. 软件架构发展的几个阶段