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

Peephole connections #1207

Merged
merged 25 commits into from Jul 29, 2016
Merged

Peephole connections #1207

merged 25 commits into from Jul 29, 2016

Conversation

codyseto
Copy link
Contributor

I implemented forward and backward of LSTM with peephole connections. GPU codes has not been implemented yet. I implemented chainer/links/connection/peephole.py and chainer/functions/activation/peephole.py referring to chainer/links/connection/lstm.py and chainer/functions/activation/lstm.py. As you can see, comment out are the same to lstm.py's one, but I'll modify it later. To calculate output gate in links, next cell state are calculated twice in links and functions. This is waste of resources. I want to improve it.

@delta2323 delta2323 added the cat:feature Implementation that introduces new interfaces. label May 31, 2016
@codyseto
Copy link
Contributor Author

codyseto commented Jun 1, 2016

To calculate a next cell state, most of forward calculation are done out of the forward function. The next cell state is passed through the connection between the cell and output gate, and I include it to "inputs" as "peep_in_o".

@codyseto
Copy link
Contributor Author

codyseto commented Jun 7, 2016

I've finished to implement links/connection/peephole.py. In addition, I've confirmed this code runs correctly by making tests/chainer_tests/links_tests/connection_tests/test_peephole.py. However, test_peephole.py is not completed because I've not implemented GPU version yet.

@codyseto codyseto changed the title [WIP] Peephole connections Peephole connections Jun 9, 2016
@codyseto
Copy link
Contributor Author

codyseto commented Jun 9, 2016

I've implemented GPU test. Now I've finished to implement Peephole connections including test codes except explanation. I'm going to include the document soon.

from chainer.links.loss import hierarchical_softmax
from chainer.links.loss import negative_sampling
from chainer.links.model import classifier
from chainer.links.normalization import batch_normalization


Copy link
Member

Choose a reason for hiding this comment

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

Restore this empty line.

self.assertIsInstance(self.link.c.data, self.link.xp.ndarray)
self.assertIsInstance(self.link.h.data, self.link.xp.ndarray)
self.link.to_gpu()
self.assertIsNot(self.link.xp, numpy)
Copy link
Member

Choose a reason for hiding this comment

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

assertIs(self.link.xp, cupy) is better

Copy link
Contributor Author

@codyseto codyseto Jun 17, 2016

Choose a reason for hiding this comment

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

This is something I want to ask you. At first, I wrote assertIs(self.link.xp, cupy) and of course import cupy at the top . However, when I pushed the code, Travis CI rejected it outputting an error message Cupy is not correctly installed . The detailed image is as below. What should I do?
screen shot 2016-06-18 at 03 04 54

@delta2323
Copy link
Member

@KotaroSetoyama I updated comments. Please check them.

@codyseto
Copy link
Contributor Author

@delta2323 Thank you for your check. I modified all parts except assertIs(self.link.xp, cupy) . I described the detail above. When you have a time, please check.

@delta2323
Copy link
Member

I believe this code should work. cuda.cupy is a module name cupy imported to Chainer.

from chainer import cuda
...
assertIs(self.link.xp, cuda.cupy)

Can I answer to your question?

@codyseto
Copy link
Contributor Author

Thank you for your advice. I confirmed the code worked without errors.

@codyseto
Copy link
Contributor Author

I found mistakes in the document and modified.

@delta2323
Copy link
Member

delta2323 commented Jun 27, 2016

Thank you for your considerable work. I checked your code and believe that it will work well. But to be honest, I cannot decide to merge this PR because I am wondering how to define the interface of RNN units as I submitted the issue. I am cautious about defining the interface because we must support backward compatibility. The situation is same as other types of RNN units like (SGU/DSGU and MGU). I am sorry for you because it is not the problem of your implementation but Chainer side's one. Once we find the solution, we are ready for merging your PR. I am appreciate you if you let me know any idea or we can discuss the matter with you.

@delta2323
Copy link
Member

Could you rename the class from Peephole to StatefulPeepholeLSTM?

@delta2323
Copy link
Member

Also, could merge or rebase the master branch?

@codyseto
Copy link
Contributor Author

I renamed the class name "Peephole" to "StatefulPeepholeLSTM"

class TestPeephole(unittest.TestCase):

def setUp(self):
self.link = links.Peephole(self.in_size, self.out_size)
Copy link
Member

Choose a reason for hiding this comment

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

Could you fix here, too?

@delta2323
Copy link
Member

Please register StatefulPeepholeLSTM to document (by adding this link to chainer/docs/source/reference/links.rst)

@delta2323
Copy link
Member

@KotaroSetoyama Thank you for your quick response. LGTM except the comments.

@@ -38,6 +39,7 @@
StatelessLSTM = lstm.StatelessLSTM
MLPConvolution2D = mlp_convolution_2d.MLPConvolution2D
Parameter = parameter.Parameter
Peephole = peephole.StatefulPeepholeLSTM
Copy link
Member

Choose a reason for hiding this comment

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

Please change the name here.

@delta2323
Copy link
Member

LGTM 👍

@delta2323 delta2323 merged commit 5d63163 into chainer:master Jul 29, 2016
@delta2323 delta2323 added this to the v1.12.1 milestone Jul 29, 2016
hvy pushed a commit that referenced this pull request Nov 29, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cat:feature Implementation that introduces new interfaces.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants