Caffe 网络结构可视化
2019獨(dú)角獸企業(yè)重金招聘Python工程師標(biāo)準(zhǔn)>>>
可以利用python接口實(shí)現(xiàn)網(wǎng)絡(luò)結(jié)構(gòu)的可視化,便于直觀理解。
最近安裝了tensorflow,發(fā)現(xiàn)caffe的draw_net腳本不好用了(AttributeError: ‘google.protobuf.pyext._message.RepeatedScalarConta’ object has no attribute ‘_values’),原因是二者的protobuf版本不兼容。caffe不支持高于3.0.0版本的protobuf.
解決方法:?
卸載當(dāng)前protobuf。(pip uninstall protobuf)?
再指定安裝低版本的,這里用的是2.5.0(pip install protobuf==2.5.0)?
可以用virtualenv創(chuàng)建獨(dú)立的Python環(huán)境
在線網(wǎng)頁(yè)繪制caffe網(wǎng)絡(luò)結(jié)構(gòu)圖的方法,其實(shí)更簡(jiǎn)潔方便:?
http://ethereon.github.io/netscope/#/editor
注:主要參考《21天實(shí)戰(zhàn)caffe》
1.準(zhǔn)備Python環(huán)境
1.1安裝Python
sudo apt-get update sudo apt-get install python-dev- 1
- 2
1.2安裝Python包管理器:pip?
這里建議通過(guò)源碼安裝,如果通過(guò)命令 sudo apt-get install python-pip 安裝,可能會(huì)出現(xiàn)類似下面的錯(cuò)誤,主要原因是上述方式安裝的pip版本較老。
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
源碼安裝pip方式如下(參考:http://www.cnblogs.com/ajianbeyourself/p/4214398.html):
wget https://bootstrap.pypa.io/get-pip.py --no-check-certificate sudo python get-pip.py- 1
- 2
或者直接更新pip:
pip install -U pip- 1
1.3通過(guò)pip安裝依賴包?
這里caffe已經(jīng)列出了依賴包及版本號(hào),在caffe源碼根目錄下的 /python/requirement.txt 中:?
Cython>=0.19.2?
numpy>=1.7.1?
scipy>=0.13.2?
scikit-image>=0.9.3?
matplotlib>=1.3.1?
ipython>=3.0.0?
h5py>=2.2.0?
leveldb>=0.191?
networkx>=1.8.1?
nose>=1.3.0?
pandas>=0.12.0?
python-dateutil>=1.4,<2?
protobuf>=2.5.0?
python-gflags>=2.0?
pyyaml>=3.10?
Pillow>=2.3.0?
six>=1.1.0
- 1
- 2
2.編譯 pycaffe
cd ${CAFFE_ROOT} make clean make make pycaffe- 1
- 2
- 3
- 4
3.繪制網(wǎng)絡(luò)結(jié)構(gòu)圖
cd ${CAFFE_ROOT} python ./python/draw_net.py ./models/bvlc_reference_caffenet/train_val.prototxt ~/Desktop/caffenet.png- 1
- 2
- 3
4.“dot” not found in path 的問(wèn)題
2016.12.01添加:
先安裝graphviz否則會(huì)出現(xiàn)類似:“dot” not found in path 的問(wèn)題?
安裝graphviz不要用pip install安裝,否則還是會(huì)找不到可執(zhí)行程序?
安裝:sudo apt-get insall graphviz?
然后安裝pydot:pip install pydot?
其中pyparsing會(huì)自動(dòng)安裝
摘自:pydot 安裝 用于caffe畫(huà)圖
轉(zhuǎn)載于:https://my.oschina.net/lilinzero/blog/884699
總結(jié)
以上是生活随笔為你收集整理的Caffe 网络结构可视化的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。
- 上一篇: 搭建mongodb集群(副本集+分片)
- 下一篇: Caffe: LMDB 及其数据转换