博主所用caffe在windows下编译生成。
配置环境说明
- 编译器:vs2013
- 操作系统:win10-64bit
- caffe-windows
- python2.7(64bit)
1 编译pycaffe
1.1 配置 CommonSettings.props 中使能python接口功能:< PythonSupport >为true
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ImportGroup Label="PropertySheets" />
<PropertyGroup Label="UserMacros">
<BuildDir>$(SolutionDir)..\Build</BuildDir>
<!--NOTE: CpuOnlyBuild and UseCuDNN flags can't be set at the same time.-->
<CpuOnlyBuild>true</CpuOnlyBuild>
<UseCuDNN>false</UseCuDNN>
<CudaVersion>7.5</CudaVersion>
<!-- NOTE: If Python support is enabled, PythonDir (below) needs to be
set to the root of your Python installation. If your Python installation
does not contain debug libraries, debug build will not work. -->
<PythonSupport>true</PythonSupport>
<!-- NOTE: If Matlab support is enabled, MatlabDir (below) needs to be
set to the root of your Matlab installation. -->
<MatlabSupport>true</MatlabSupport>
<CudaDependencies></CudaDependencies>
<!-- Set CUDA architecture suitable for your GPU.
Setting proper architecture is important to mimize your run and compile time. -->
<CudaArchitecture>compute_35,sm_35;compute_52,sm_52</CudaArchitecture>
<!-- CuDNN 3 and 4 are supported -->
<CuDnnPath></CuDnnPath>
<ScriptsDir>$(SolutionDir)\scripts</ScriptsDir>
</PropertyGroup>
1.2 编译生成pycaffe
编译解决方案,注意需要在【release】模式下,因为在debug下找不到 python对应的调试版本。
在[caffe_root]\Build\x64\Release 目录下会生成pycaffe目录。我一般会把内部的caffe文件夹直接拷贝到python包管理目录site-packages中。
2 绘制网络图
利用python目录下的draw_net.py 工具,绘制网络图;
出现 Exception: “dot.exe” not found in path. 错误
先去这个网址http://www.graphviz.org/Download_windows.php将graphviz-2.38.msi下下来,进行安装,可以发现它的bin目录下有这个我们需要的dot.exe,将这个bin目录添加到系统的环境变量中去即可。注意:重启电脑。
python draw_net.py lenet_train_test.prototxt lenet5.png
python draw_net.py train_val-alex.prototxt alex.png
lenet5网络图:
alexnet 网络图:
googlenet网络图: