In training the network can use other people's Pre-train model to initialize the network, Caffe can realize the transformation of two network parameters, the precondition is the transformation of the layer parameter design is consistent, the following procedure is to convert three convolution layer and three full-connection layer parameters, Python code is as follows:
ImportCaffecaffe.set_mode_gpu () train_net= Caffe.net ('/home/python_code/caffe/trainmodel.prototxt', '/home/python_code/caffe/gendernet_50000.caffemodel', Caffe. TEST) Test_net= Caffe.net ('/home/python_code/caffe/deploy.prototxt', Caffe. TEST) Test_net.save ('/home/python_code/caffe/gendernet.caffemodel') Params= ['CONV1','Conv2','Conv3','Fc6','Fc7','Fc8']params_trans= ['CONV1','Conv2','Conv3','Fc6','Fc7','Fc8']train_params= {pr: (train_net.params[pr][0].data, Train_net.params[pr][1].data) forprinchParams}test_params= {pr: (test_net.params[pr][0].data, Test_net.params[pr][1].data) forprinchParams_trans} forPr_train, Pr_testinchzip (params, Params_trans): Test_params[pr_test][0].flat=Train_params[pr_train][0].flat test_params[pr_test][1][...] = train_params[pr_train][1]test_net.save ('/home/python_code/caffe/gendernet.caffemodel')
caffe--Network parameter Conversion