Skip to content
This repository has been archived by the owner on Nov 17, 2023. It is now read-only.

add import_ for SymbolBlock #11127

Merged
merged 12 commits into from
Jun 14, 2018
Merged

add import_ for SymbolBlock #11127

merged 12 commits into from
Jun 14, 2018

Conversation

piiswrong
Copy link
Contributor

Description

(Brief description on what this PR is about)

Checklist

Essentials

Please feel free to remove inapplicable items for your PR.

  • The PR title starts with [MXNET-$JIRA_ID], where $JIRA_ID refers to the relevant JIRA issue created (except PRs with tiny changes)
  • Changes are complete (i.e. I finished coding on this PR)
  • All changes have test coverage:
  • Unit tests are added for small changes to verify correctness (e.g. adding a new operator)
  • Nightly tests are added for complicated/long-running ones (e.g. changing distributed kvstore)
  • Build tests will be added for build configuration changes (e.g. adding a new build option with NCCL)
  • Code is well-documented:
  • For user-facing API changes, API doc string has been updated.
  • For new C++ functions in header files, their functionalities and arguments are documented.
  • For new examples, README.md is added to explain the what the example does, the source of the dataset, expected performance on test set and reference to the original paper if applicable
  • Check the API doc at http://mxnet-ci-doc.s3-accelerate.dualstack.amazonaws.com/PR-$PR_ID/$BUILD_ID/index.html
  • To the my best knowledge, examples are either not affected by this change, or have been fixed to be compatible with this change

Changes

  • Feature1, tests, (and when applicable, API doc)
  • Feature2, tests, (and when applicable, API doc)

Comments

  • If this change is a backward incompatible change, why must this change be made.
  • Interesting edge cases to note here

@piiswrong piiswrong requested a review from szha as a code owner June 1, 2018 23:05
@@ -762,7 +762,7 @@ def test_export():
model = gluon.model_zoo.vision.resnet18_v1(
prefix='resnet', ctx=ctx, pretrained=True)
model.hybridize()
data = mx.nd.random.normal(shape=(1, 3, 224, 224))
data = mx.nd.random.normal(shape=(1, 3, 32, 32))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

any specific reason for this change?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

faster

@piiswrong
Copy link
Contributor Author

@ThomasDelteil

@@ -885,6 +885,50 @@ class SymbolBlock(HybridBlock):
>>> x = mx.nd.random.normal(shape=(16, 3, 224, 224))
>>> print(feat_model(x))
"""
@staticmethod
def import_(symbol_file, input_names, param_file=None, ctx=None):
Copy link
Contributor

@ThomasDelteil ThomasDelteil Jun 4, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think import_ is a great name, even though I understand that we want to be as close as possible to .export and import being a key-word makes it impossible to use .import().
I would suggest adding an alias to export, export_symbols export_to_symbol export_hybridized, etc and have the matching one for import. That way it would be clearer, as adding a _ suffix is not a conventionnal thing to do and is close to the use of _ as a prefix, which is for private functions.

Copy link
Contributor

@ThomasDelteil ThomasDelteil left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think imports is a good compromise in terms of naming 👍

szha
szha previously requested changes Jun 7, 2018
Copy link
Member

@szha szha left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't believe the save_params change is a step in the right direction.

present in this Block.
"""
warnings.warn("load_params is deprecated. Please use load_parameters.")
import pdb;pdb.set_trace()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove these pdb statements here and elsewhere ?

@ThomasDelteil
Copy link
Contributor

ThomasDelteil commented Jun 7, 2018

Can you please update the tutorial here: https://github.com/apache/incubator-mxnet/blob/master/docs/tutorials/gluon/save_load_params.md to show the new simpler usage of .imports() ? thanks!

Just read the tutorial and noticed a few things that are wrong because of how it was iteratively updated:
L13 and L243 have references to model.load_checkpoint that are not correct and should be updated to reference the new .imports() API, if you don't mind doing it as part of this PR.

Path to file.
"""
warnings.warn("save_params is deprecated. Please use save_parameters.")
self.collect_params().save(filename, strip_prefix=self.prefix)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

let's not make this change to the save_params.

filename : str
Path to file.
"""
warnings.warn("save_params is deprecated. Please use save_parameters.")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

shall we add something about export? Something like "If you are using an hybridized model and want to serialize it to obtain the network structure and parameters, please refer to HybridBlock.export()"

@szha szha dismissed their stale review June 12, 2018 03:39

save_params change has been reverted.

@anirudh2290
Copy link
Member

Wasn't the final decision to provide deprecation warning for save_params and load_params and provide new api for save_parameter and load_parameter ? Can you please explain.

@szha
Copy link
Member

szha commented Jun 12, 2018

@anirudh2290, no, such change would break users who are on 1.2.0.

@@ -61,7 +61,7 @@ def build_lenet(net):
net.add(gluon.nn.Dense(512, activation="relu"))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

L13 there is also "load_checkpoint and load methods" -> "imports method

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we can make this change as part of another PR to avoid another round of CI.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sorry didnt realize this was already in.

@piiswrong piiswrong merged commit 66ab27e into apache:master Jun 14, 2018
anirudh2290 pushed a commit to anirudh2290/mxnet that referenced this pull request Jun 14, 2018
anirudh2290 pushed a commit to anirudh2290/mxnet that referenced this pull request Jun 15, 2018
anirudh2290 pushed a commit to anirudh2290/mxnet that referenced this pull request Jun 15, 2018
anirudh2290 pushed a commit to anirudh2290/mxnet that referenced this pull request Jun 15, 2018
anirudh2290 pushed a commit that referenced this pull request Jun 15, 2018
zheng-da pushed a commit to zheng-da/incubator-mxnet that referenced this pull request Jun 28, 2018
* add import_ for SymbolBlock

* fix

* Update block.py

* add save_parameters

* fix

* fix lint

* fix

* fix

* fix

* fix

* fix

* Update save_load_params.md
XinYao1994 pushed a commit to XinYao1994/incubator-mxnet that referenced this pull request Aug 29, 2018
* add import_ for SymbolBlock

* fix

* Update block.py

* add save_parameters

* fix

* fix lint

* fix

* fix

* fix

* fix

* fix

* Update save_load_params.md
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants