caffe--Network parameter Conversion

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.