直接撸代码~

 1 import caffe
 2 import numpy as np
 3 
 4 caffe.set_mode_cpu()
 5 net = caffe.Net('myprototxt.prototxt', 'mycaffemodel.caffemodel', caffe.TEST)
 6 netNew = caffe.Net('myprototxt2.prototxt', 'mycaffemodel2.caffemodel', caffe.TEST)
 7 for k, v in net.params.items():
 8     #print (k, v[0].data.shape)
 9     #print np.size(net.params[k])
10     for i in range(np.size(net.params[k])):
11         netNew.params[k][i].data[:] = np.copy(net.params[k][i].data[:])
12 params = {('layer_name_new','layer_name_old')}
13 for k, v in params:
14     for i in range(np.size(net.params[v])):
15         netNew.params[k][i].data[:] = np.copy(net.params[v][i].data[:])
16 netNew.save('mynewmodel.caffemodel')

 

相关文章:

  • 2022-12-23
  • 2021-08-30
  • 2021-12-28
  • 2022-12-23
  • 2021-08-05
  • 2022-12-23
  • 2021-12-31
  • 2022-12-23
猜你喜欢
  • 2021-10-22
  • 2021-07-13
  • 2022-12-23
  • 2022-12-23
  • 2021-05-30
  • 2022-12-23
  • 2021-11-16
相关资源
相似解决方案