You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mxnet.apache.org by GitBox <gi...@apache.org> on 2019/01/29 06:24:36 UTC

[GitHub] MaJieCornell opened a new issue #14017: Loading parameters for pretrained gluon model

MaJieCornell opened a new issue #14017: Loading parameters for pretrained gluon model
URL: https://github.com/apache/incubator-mxnet/issues/14017
 
 
   Hi,
   
   Currently I am using Gluon to do some transfer learning project. What I am trying to do is loading some parameters from a pretrained network to my new model and fine tune on that. However, I just want to load part of the parameters and left some of them to get random initialized. 
   
   In MXNet what I can do is loading the pretrained parameters first and then manually delete some of the parameters I don't want to use from the parameter dictionary. But in gluon seems like we only have interface to load parameters directly from model files and I am not able to delete the parameters at intermediate stage. The only document regarding this issue I find is this: 
   
   https://mxnet.incubator.apache.org/versions/master/tutorials/onnx/fine_tuning_gluon.html
   
   And code example is like:
   ```
   pre_trained = gluon.nn.SymbolBlock(outputs=new_sym, inputs=mx.sym.var('data_0'))
   net_params = pre_trained._collect_params_with_prefix()
   for param in new_arg_params:
       if param in net_params:
           net_params[param]._load_init(new_arg_params[param], ctx=ctx)
   for param in new_aux_params:
        if param in net_params:
             net_params[param]._load_init(new_aux_params[param], ctx=ctx)
   ```
   
   It will rely on some of the internal function like "_load_init" and "_collect_params_with_prefix". My concern is that will these internal function deprecated and not supported some day? And what is most recommended way of handling it? Since we are using Gluon to build some critical project then we don't want to use some function which will probably not get supported in the future and deprecated silently. 
   
   Thanks,
   Jie

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services