实验平台: ubuntu 14.04, python2.7, caffe当前最新版
有时候我们需要查看、修改caffe的网络参数,苦于caffe本身是c++编写,如果想从c++中提取,明显这个太困难。我们使用python来实现这个,每一步都可以查看参数,所以就容易很多。
import sys
import os
# Add caffe package
caffe_python_dir = "your/caffe-master/python"
sys.path.append(caffe_python_dir)
if not os.path.exists(caffe_python_dir):
print "python caffe not found."
exit(-1)
import caffe
import numpy as np
from PIL import Image
# load image, switc