Mxnet View the network structure of the model params

Source: Internet
Author: User
Tags mxnet

Importmxnet as MXImportPDBdefload_checkpoint ():"""Load model checkpoint from file.     :p Aram Prefix:prefix of model name.     :p Aram Epoch:epoch Number of model we would like to load.  : Return: (Arg_params, Aux_params) Arg_params:dict of STR to ndarray Model parameter, dict of the name to Ndarray     of net ' s weights.     Aux_params:dict of STR to ndarray Model parameter, dict of the name to Ndarray of net ' s auxiliary states. """save_dict= Mx.nd.load ('Model-0000.params') Arg_params={} aux_params= {}       forKvinchSave_dict.items (): TP, name= K.split (':', 1)          ifTP = ='Arg': Arg_params[name]=vifTP = ='aux': Aux_params[name]=vreturnArg_params, Aux_paramsdefConvert_context (params, CTX):""":p Aram Params:dict of str to Ndarray:p Aram Ctx:the context to convert to:return:dict of STR of Ndarr Ay with context ctx"""New_params=dict () forKvinchParams.items (): New_params[k]=V.as_in_context (CTX)#Print New_params[0]    returnNew_paramsdefLoad_param (Convert=false, ctx=None):"""wrapper for load checkpoint:p Aram Prefix:prefix of model name.     :p Aram Epoch:epoch Number of model we would like to load. :p Aram Convert:reference model should be converted to GPU Ndarray first:p Aram Ctx:if convert then CTX must be Desig     Nated. : Return: (Arg_params, Aux_params)"""Arg_params, Aux_params=Load_checkpoint ()ifConvert:ifCTx isNone:ctx=mx.cpu () arg_params=Convert_context (Arg_params, CTX) aux_params=Convert_context (Aux_params, CTX)returnArg_params, Aux_paramsif __name__=='__main__': Result=Load_param (); #pdb.set_trace ()        Print 'result is'          #Print Result         forDicinchResult: forKeyinchDIC:Print(Key,dic[key].shape)#print ' One of results is: '        #print result[0][' fc2_weight '].asnumpy ()

Python showmxmodel.py 2>&1 | Tee Log.txt
Result is
(' Stage3_unit2_bn1_beta ', (256L,))
(' Stage3_unit2_bn3_beta ', (256L,))
(' Stage3_unit11_bn1_gamma ', (256L,))
(' Stage3_unit5_bn3_gamma ', (256L,))
(' Stage3_unit3_conv1_weight ', (256L, 256L, 3L, 3L))
(' Stage2_unit1_bn3_gamma ', (128L,))
(' Stage3_unit4_conv1_weight ', (256L, 256L, 3L, 3L))
(' Stage3_unit12_bn3_beta ', (256L,))
(' Stage2_unit2_bn3_beta ', (128L,))
(' Conv0_weight ', (64L, 3L, 3L, 3L))
(' Stage3_unit11_relu1_gamma ', (256L,))
(' Stage4_unit1_conv1sc_weight ', (512L, 256L, 1L, 1L))
(' Stage3_unit1_conv1sc_weight ', (256L, 128L, 1L, 1L))
(' Bn1_beta ', (512L,))
(' Stage1_unit2_bn2_beta ', (64L,))
(' Stage3_unit2_conv2_weight ', (256L, 256L, 3L, 3L))
(' Stage1_unit2_conv1_weight ', (64L, 64L, 3L, 3L))
(' Stage3_unit14_bn2_beta ', (256L,))
(' Stage4_unit2_bn3_beta ', (512L,))
(' Stage3_unit8_bn1_gamma ', (256L,))
(' Stage3_unit7_bn1_gamma ', (256L,))
(' Stage2_unit3_bn1_beta ', (128L,))
(' Stage2_unit4_conv1_weight ', (128L, 128L, 3L, 3L))
(' Stage3_unit2_bn2_gamma ', (256L,))
(' Stage1_unit1_conv1_weight ', (64L, 64L, 3L, 3L))
(' Stage3_unit9_conv2_weight ', (256L, 256L, 3L, 3L))
(' Stage3_unit13_conv1_weight ', (256L, 256L, 3L, 3L))
(' Stage3_unit1_relu1_gamma ', (256L,))
(' Stage4_unit1_bn3_beta ', (512L,))
(' Stage2_unit1_bn2_beta ', (128L,))
(' Stage3_unit14_conv1_weight ', (256L, 256L, 3L, 3L))
(' Stage3_unit8_bn1_beta ', (256L,))
(' Stage3_unit11_conv1_weight ', (256L, 256L, 3L, 3L))
(' Stage1_unit1_bn3_gamma ', (64L,))
(' Stage2_unit2_conv2_weight ', (128L, 128L, 3L, 3L))
(' Stage4_unit2_bn1_gamma ', (512L,))
(' Stage3_unit3_bn1_gamma ', (256L,))
(' Stage1_unit3_bn2_gamma ', (64L,))
(' Stage1_unit3_bn3_gamma ', (64L,))
(' Stage4_unit2_relu1_gamma ', (512L,))
(' Stage3_unit10_conv2_weight ', (256L, 256L, 3L, 3L))
(' Stage3_unit12_conv1_weight ', (256L, 256L, 3L, 3L))
(' Stage3_unit2_relu1_gamma ', (256L,))
(' Stage3_unit10_bn2_beta ', (256L,))
(' Stage2_unit3_bn3_gamma ', (128L,))
(' Stage2_unit3_bn2_beta ', (128L,))
(' Stage3_unit8_bn3_beta ', (256L,))
(' Fc1_gamma ', (512L,))
(' Stage3_unit14_bn3_gamma ', (256L,))
(' Stage3_unit9_bn3_gamma ', (256L,))
(' Stage2_unit3_bn3_beta ', (128L,))
(' Stage3_unit1_sc_gamma ', (256L,))
(' Stage3_unit7_bn1_beta ', (256L,))
(' Stage1_unit2_bn3_beta ', (64L,))
(' Stage3_unit14_relu1_gamma ', (256L,))
(' Stage3_unit13_bn2_beta ', (256L,))
(' Stage2_unit1_conv1sc_weight ', (128L, 64L, 1L, 1L))
(' Bn0_beta ', (64L,))
(' Stage3_unit12_bn1_gamma ', (256L,))
(' Stage2_unit1_sc_gamma ', (128L,))
(' Relu0_gamma ', (64L,))
(' Stage2_unit2_bn2_gamma ', (128L,))
(' Stage3_unit4_relu1_gamma ', (256L,))

Mxnet View the network structure of the model params

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.