acphile commented on issue #18412:
URL: 
https://github.com/apache/incubator-mxnet/issues/18412#issuecomment-642383991


   Thanks @leezu . Based on the suggestions, I remove the method `set_prefix` 
and separate the param.name and structure based naming scheme. Here are the 
details
   ## Parameter name
   Once a parameter is created, `param.name` would not be changed in the 
following operations. It is in the form of `param_{uuid4}_{name}`, where `name` 
is from `__init __` parameter. Here `name` is optional, default `weight`. It is 
mainly used to denote which default initialization should be used.
   We use `param.name` as the name of a parameter's symbol representation.
   ## collect_params()
   It returns a `dict`, where the keys are structural names of parameters, like 
   `{'hidden1.weight': Parameter (shape=(3, -1), dtype=float32), 
'hidden1.bias': Parameter (shape=(3,), dtype=float32)}`
   Note that we use `.` as the linking character again because the structured 
based naming scheme is no longer used in the symbol representation.
   ## Save and Load
   For `HybridBlock`, there are two ways to save and load parameters:
   ### save_parameters() and load_parameters()
   In `save_parameters()`, we use `structural name` to save parameters, and 
they should be loaded by `load_parameters()`, which loads parameters based on a 
model's structure.
   ### HybridBlock.export and SymbolBlock.imports
   In `export`, we only save parameters using `param.name` without `structural 
name`. The param file should be loaded in SymbolBlock.imports.
   ## SymbolBlock
   When using `SymbolBlock.imports`, keys in `self.param` would be the loaded 
parameters' names `param.name`.
   While in `SymbolBlock(outputs, inputs, params=None)`, if you provide like 
`params=net.collect_params()`,  keys in `self.param` would be structural names 
of `net`'s parameters (keys in net.collect_params() ). It is often used in this 
situation that a `SymbolBlock` is a children block of another `HybridBlock`. 
Otherwise, keys in `self.param` would be the loaded parameters' names 
`param.name`.


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to