Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve Link interface #4250

Closed
beam2d opened this issue Jan 29, 2018 · 7 comments
Closed

Improve Link interface #4250

beam2d opened this issue Jan 29, 2018 · 7 comments
Assignees
Labels
cat:enhancement Implementation that does not break interfaces. prio:high High priority. Urgent and needs to be worked on as soon as possible. stale Not updated for a longer period of time.
Milestone

Comments

@beam2d
Copy link
Member

beam2d commented Jan 29, 2018

I'm thinking about improving the interface and class organization of Link as follows.

  1. Unify Link and Chain. Link will have the almost same interface as Chain (instead of __init__: init will accept both parameters, tuple of shape/dtype of parameters, and links). Child/parameter initializations via __init__, add_link, and add_param will be de-deprecated (they will be served for the official support of container-style usage of link, together with the next bullet point).
  2. Allow a list/tuple/dict of parameters/links to be registered to Link. Users can then use these standard containers to represent a set of parameters/links. ChainList will be left for backward compatibility.
  3. Introduce a way to skip the hierarchy when wrapping a link/parameter by another link. Typical use case will be to use L.Classifier without introducing predictor/ to the link paths.

1 and 2 are relevant to #4106, while 3 is relevant to #2575. These changes will improve the simplicity and flexibility of Link interface, which is made more Pythonic.

I think these changes can be made without breaking most of the compatibility. Unification part of 1 has already been done at my local branch: https://github.com/beam2d/chainer/tree/unify-link-chain. If this direction is acceptable, I will make a PR for it and continue working on other parts.

@stale
Copy link

stale bot commented Apr 29, 2018

This issue has been automatically marked as stale because it has not had recent activity. It will be closed after 30 days if no further activity occurs. Thank you for your contributions.

@stale stale bot added the stale Not updated for a longer period of time. label Apr 29, 2018
@kmaehashi kmaehashi added the cat:enhancement Implementation that does not break interfaces. label May 7, 2018
@stale stale bot removed the stale Not updated for a longer period of time. label May 7, 2018
@toslunar
Copy link
Member

One difference between Link and Chain is

>>> l = chainer.Link()
>>> with l.init_scope():
...  l.a = chainer.Link()
...  l.a = chainer.Link()
...
>>> l = chainer.Chain()
>>> with l.init_scope():
...  l.a = chainer.Link()
...  l.a = chainer.Link()
...
Traceback (most recent call last):
  File "<stdin>", line 3, in <module>
  File "/Users/tos/GitHub/chainer/chainer/link.py", line 802, in __setattr__
    'cannot register a new link %s: attribute exists' % name)
AttributeError: cannot register a new link a: attribute exists

@kmaehashi kmaehashi self-assigned this Jun 18, 2018
@kmaehashi kmaehashi added this to the v5 milestone Jun 18, 2018
@kmaehashi kmaehashi added the prio:high High priority. Urgent and needs to be worked on as soon as possible. label Aug 27, 2018
@kmaehashi kmaehashi modified the milestones: v5, v5.0.0 Sep 27, 2018
@kmaehashi kmaehashi modified the milestones: v5.0.0, v6 Oct 23, 2018
@stale
Copy link

stale bot commented Jan 30, 2019

This issue has been automatically marked as stale because it has not had recent activity. It will be closed after 30 days if no further activity occurs. Thank you for your contributions.

@stale stale bot added the stale Not updated for a longer period of time. label Jan 30, 2019
@niboshi niboshi removed the stale Not updated for a longer period of time. label Feb 3, 2019
@stale
Copy link

stale bot commented May 4, 2019

This issue has been automatically marked as stale because it has not had recent activity. It will be closed after 30 days if no further activity occurs. Thank you for your contributions.

@stale stale bot added the stale Not updated for a longer period of time. label May 4, 2019
@stale
Copy link

stale bot commented Jun 3, 2019

This issue is closed as announced. Feel free to re-open it if needed.

@stale stale bot closed this as completed Jun 3, 2019
@niboshi niboshi reopened this Jun 29, 2019
@stale stale bot removed the stale Not updated for a longer period of time. label Jun 29, 2019
@stale
Copy link

stale bot commented Sep 27, 2019

This issue has been automatically marked as stale because it has not had recent activity. It will be closed after 30 days if no further activity occurs. Thank you for your contributions.

@stale stale bot added the stale Not updated for a longer period of time. label Sep 27, 2019
@stale
Copy link

stale bot commented Oct 27, 2019

This issue is closed as announced. Feel free to re-open it if needed.

@stale stale bot closed this as completed Oct 27, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cat:enhancement Implementation that does not break interfaces. prio:high High priority. Urgent and needs to be worked on as soon as possible. stale Not updated for a longer period of time.
Projects
None yet
Development

No branches or pull requests

4 participants