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

Standard interface of RNN units #1271

Closed
delta2323 opened this issue Jun 14, 2016 · 6 comments
Closed

Standard interface of RNN units #1271

delta2323 opened this issue Jun 14, 2016 · 6 comments
Labels
cat:enhancement Implementation that does not break interfaces. stale Not updated for a longer period of time.

Comments

@delta2323
Copy link
Member

delta2323 commented Jun 14, 2016

Currently, several types of RNN units are implemented (stateful/stateless, LSTM/GRU). And we also have PRs that implement other kind of RNN units (SGU, DSGU (#1115), MGU (#1101), peephole (#1207), stacked GRU and stacked LSTM (#1124) etc.).

It would be cumbersome if these RNN units had different APIs as we sometimes switch RNN units within the model without change the interfaces. So it is preferable for those RNN units to have standard interface that are common to them.

@unnonouno
Copy link
Member

I think each RNN unit function f can be abstracted with four components. I assumes f is a Link object with parameter W (so called stateless XXX).

  • input: x
  • output: y
  • hidden state: h
  • parameters: W

Each unit f gets x and h, and it returns y and updated h: y, h' = f(x, h)
In some units, y is equivalent to h (such as GRU), or h contains y (such as LSTM).
When a user want to stack units, a second unit function gets output of a first unit function.

h1 = 0
h2 = 0
y1, h1' = f1(x, h1)
y2, h2' = f2(y1, h2)

A statefull unit s has an attribute h, and when __call__ is called, it updates its own hidden state.

def __call__(x):
    y, self.h = f(x, self.h)
    return y

For variable length inputs, we need return parts of hidden states as y. See #1183

The interface of cuDNN's RNN helps you because it supports many types of RNNs in one API.

@delta2323
Copy link
Member Author

@unnonouno Thank you for your proposal. My vague idea was almost same as you. And also thank you for suggestion of cuDNN RNN's API. How do you think of the separation of Function and Link, as we did in LSTM?

@unnonouno
Copy link
Member

Function is not mandatory. I mean, users can make RNN unit as a method with combination of existing Functions. I feel Link is enough though someone may need a method when they want to make parameter matrices from other functions. I don't have such a use case.

@delta2323
Copy link
Member Author

delta2323 commented Jul 5, 2016

I agree with you in that Function is not mandatory because for example, GRU is difficult to isolate "function" part.

@delta2323 delta2323 added cat:enhancement Implementation that does not break interfaces. cat:feature Implementation that introduces new interfaces. and removed cat:feature Implementation that introduces new interfaces. labels Jul 26, 2016
@stale
Copy link

stale bot commented Oct 23, 2017

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 Oct 23, 2017
@stale
Copy link

stale bot commented Nov 22, 2017

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

@stale stale bot closed this as completed Nov 22, 2017
hvy added a commit that referenced this issue Nov 29, 2018
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. stale Not updated for a longer period of time.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants