This is an automated email from the ASF dual-hosted git repository.
anirudh2290 pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-mxnet.git
The following commit(s) were added to refs/heads/master by this push:
new 496b0f2 [MXNET-532] Clarify documentation of save_parameters(),
load_parameters() (#11210)
496b0f2 is described below
commit 496b0f25eaa19034362d0934c8799cbcba3e499e
Author: Thomas Delteil <[email protected]>
AuthorDate: Thu Jun 14 14:10:11 2018 -0700
[MXNET-532] Clarify documentation of save_parameters(), load_parameters()
(#11210)
* flipping official and alternative
* Update block.py
* Add new line
* fix trailing whitespaces
* clarify docs
* Update block.py
* Update block.py
* fix typo
* trailing whitespace
* Trigger build
---
docs/tutorials/index.md | 2 +-
python/mxnet/gluon/block.py | 24 ++++++++++++++++++++----
2 files changed, 21 insertions(+), 5 deletions(-)
diff --git a/docs/tutorials/index.md b/docs/tutorials/index.md
index a970c0a..e095a83 100644
--- a/docs/tutorials/index.md
+++ b/docs/tutorials/index.md
@@ -38,7 +38,7 @@ Select API:
* [Visual Question
Answering](http://gluon.mxnet.io/chapter08_computer-vision/visual-question-answer.html)
<img
src="https://upload.wikimedia.org/wikipedia/commons/6/6a/External_link_font_awesome.svg"
alt="External link" height="15px" style="margin: 0px 0px 3px 3px;"/>
* Practitioner Guides
* [Multi-GPU
training](http://gluon.mxnet.io/chapter07_distributed-learning/multiple-gpus-gluon.html)
<img
src="https://upload.wikimedia.org/wikipedia/commons/6/6a/External_link_font_awesome.svg"
alt="External link" height="15px" style="margin: 0px 0px 3px 3px;"/>
- * [Checkpointing and Model Serialization (a.k.a. saving and
loading)](http://gluon.mxnet.io/chapter03_deep-neural-networks/serialization.html)
<img
src="https://upload.wikimedia.org/wikipedia/commons/6/6a/External_link_font_awesome.svg"
alt="External link" height="15px" style="margin: 0px 0px 3px 3px;"/>
([Alternative](/tutorials/gluon/save_load_params.html))
+ * [Checkpointing and Model Serialization (a.k.a. saving and
loading)](/tutorials/gluon/save_load_params.html) <img
src="https://upload.wikimedia.org/wikipedia/commons/6/6a/External_link_font_awesome.svg"
alt="External link" height="15px" style="margin: 0px 0px 3px 3px;"/>
([Alternative](http://gluon.mxnet.io/chapter03_deep-neural-networks/serialization.html))
* [Inference using an ONNX
model](/tutorials/onnx/inference_on_onnx_model.html)
* [Fine-tuning an ONNX model on
Gluon](/tutorials/onnx/fine_tuning_gluon.html)
* [Visualizing Decisions of Convolutional Neural
Networks](/tutorials/vision/cnn_visualization.html)
diff --git a/python/mxnet/gluon/block.py b/python/mxnet/gluon/block.py
index f8f01fc..293fafa 100644
--- a/python/mxnet/gluon/block.py
+++ b/python/mxnet/gluon/block.py
@@ -269,12 +269,12 @@ class Block(object):
children's Parameters(default), also can returns the select
:py:class:`ParameterDict`
which match some given regular expressions.
- For example, collect the specified parameter in ['conv1_weight',
'conv1_bias', 'fc_weight',
+ For example, collect the specified parameters in ['conv1_weight',
'conv1_bias', 'fc_weight',
'fc_bias']::
model.collect_params('conv1_weight|conv1_bias|fc_weight|fc_bias')
- or collect all paramters which their name ends with 'weight' or
'bias', this can be done
+ or collect all parameters whose names end with 'weight' or 'bias',
this can be done
using regular expressions::
model.collect_params('.*weight|.*bias')
@@ -310,6 +310,18 @@ class Block(object):
def save_parameters(self, filename):
"""Save parameters to file.
+ This function is to be used to save parameters of a Gluon model, note
that
+ the saved parameters are not meant to be loaded in a different
language binding for now.
+ Saving parameters using `.save_parameters()` is different than
+ `.collect_params().save()` and `.save_params()`, which are deprecated
ways
+ to save the parameters of a model and should be avoided.
+
+ If your model is hybridizable and you want to export a serialized
version of the
+ structure of the model as well as its parameters please refer to
+ :py:meth:`HybridBlock.export`. Such model can then be loaded back in
any language binding
+ or even in Gluon using a :py:class:`SymbolBlock`.
+ Refer to this tutorial for a complete overview of saving/loading
models with
+ MXNet:
https://mxnet.incubator.apache.org/tutorials/gluon/save_load_params.html
Parameters
----------
@@ -338,13 +350,17 @@ class Block(object):
def load_parameters(self, filename, ctx=None, allow_missing=False,
ignore_extra=False):
"""Load parameters from file.
+ This function is to be used to load parameters of a Gluon model that
were
+ saved using the `.save_parameters()` function. Any other use is
undefined behaviour.
+ Refer to this tutorial for a complete overview of saving/loading
models with
+ MXNet:
https://mxnet.incubator.apache.org/tutorials/gluon/save_load_params.html
Parameters
----------
filename : str
Path to parameter file.
ctx : Context or list of Context, default cpu()
- Context(s) initialize loaded parameters on.
+ Context(s) to initialize loaded parameters on.
allow_missing : bool, default False
Whether to silently skip loading parameters not represents in the
file.
ignore_extra : bool, default False
@@ -387,7 +403,7 @@ class Block(object):
filename : str
Path to parameter file.
ctx : Context or list of Context, default cpu()
- Context(s) initialize loaded parameters on.
+ Context(s) to initialize loaded parameters on.
allow_missing : bool, default False
Whether to silently skip loading parameters not represents in the
file.
ignore_extra : bool, default False
--
To stop receiving notification emails like this one, please contact
[email protected].