caffemodel的读取与修改

直接撸代码~

 import caffe
import numpy as np caffe.set_mode_cpu()
net = caffe.Net('myprototxt.prototxt', 'mycaffemodel.caffemodel', caffe.TEST)
netNew = caffe.Net('myprototxt2.prototxt', 'mycaffemodel2.caffemodel', caffe.TEST)
for k, v in net.params.items():
#print (k, v[0].data.shape)
#print np.size(net.params[k])
for i in range(np.size(net.params[k])):
netNew.params[k][i].data[:] = np.copy(net.params[k][i].data[:])
params = {('layer_name_new','layer_name_old')}
for k, v in params:
for i in range(np.size(net.params[v])):
netNew.params[k][i].data[:] = np.copy(net.params[v][i].data[:])
netNew.save('mynewmodel.caffemodel')
上一篇:小程序解析html(使用wxParse)


下一篇:Position a child div relative to parent container in CSS: [设置 子DIV位置 跟 父DIV相关联]