-
Notifications
You must be signed in to change notification settings - Fork 349
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
Adding a positive bias to the LSTM forget gate #840
Open
ablavatski
wants to merge
5
commits into
mila-iqia:master
Choose a base branch
from
ablavatski:positive_bias_to_LSTM_forget_gate
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 3 commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
cf07842
According to the "Rafal Jozefowicz, Wojciech Zaremba, Ilya Sutskever,…
e7dd8aa
Scrutinizer issues "blocks/bricks/recurrent.py:334 in public class …
07ebc76
Scrutinizer issues "blocks/bricks/recurrent.py:420(398):49: E128 co…
82c9e5e
Unnecessary reference was deleted. Bug with not using bias for forget…
c8fc509
Scrutinizer issue "tests/bricks/test_recurrent.py:149 (151):26: E128…
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,7 +12,7 @@ | |
from blocks.bricks import Initializable, Logistic, Tanh, Linear | ||
from blocks.bricks.base import Application, application, Brick, lazy | ||
from blocks.initialization import NdarrayInitialization | ||
from blocks.roles import add_role, WEIGHT, INITIAL_STATE | ||
from blocks.roles import add_role, WEIGHT, BIAS, INITIAL_STATE | ||
from blocks.utils import (pack, shared_floatx_nans, shared_floatx_zeros, | ||
dict_union, dict_subset, is_shared_variable) | ||
from blocks.bricks.parallel import Fork | ||
|
@@ -354,6 +354,9 @@ class LSTM(BaseRecurrent, Initializable): | |
networks*, arXiv preprint arXiv:1308.0850 (2013). | ||
.. [HS97] Sepp Hochreiter, and Jürgen Schmidhuber, *Long Short-Term | ||
Memory*, Neural Computation 9(8) (1997), pp. 1735-1780. | ||
.. [Jozefowicz15] Jozefowicz R., Zaremba W. and Sutskever I., *An | ||
Empirical Exploration of Recurrent Network Architectures*, Journal | ||
of Machine Learning Research 37 (2015). | ||
|
||
Parameters | ||
---------- | ||
|
@@ -412,10 +415,20 @@ def _allocate(self): | |
self.W_state, self.W_cell_to_in, self.W_cell_to_forget, | ||
self.W_cell_to_out, self.initial_state_, self.initial_cells] | ||
|
||
if self.use_bias: | ||
self.b_cell_to_forget = shared_floatx_nans((self.dim,), | ||
name='b_cell_to_forget') | ||
add_role(self.b_cell_to_forget, BIAS) | ||
self.parameters.append(self.b_cell_to_forget) | ||
|
||
def _initialize(self): | ||
for weights in self.parameters[:4]: | ||
self.weights_init.initialize(weights, self.rng) | ||
|
||
if self.use_bias: | ||
for biases in self.parameters[-1:]: | ||
self.biases_init.initialize(biases, self.rng) | ||
|
||
@recurrent(sequences=['inputs', 'mask'], states=['states', 'cells'], | ||
contexts=[], outputs=['states', 'cells']) | ||
def apply(self, inputs, states, cells, mask=None): | ||
|
@@ -459,7 +472,8 @@ def slice_last(x, no): | |
in_gate = tensor.nnet.sigmoid(slice_last(activation, 0) + | ||
cells * self.W_cell_to_in) | ||
forget_gate = tensor.nnet.sigmoid(slice_last(activation, 1) + | ||
cells * self.W_cell_to_forget) | ||
cells * self.W_cell_to_forget + | ||
self.b_cell_to_forget) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is going to fail if |
||
next_cells = (forget_gate * cells + | ||
in_gate * nonlinearity(slice_last(activation, 2))) | ||
out_gate = tensor.nnet.sigmoid(slice_last(activation, 3) + | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sphynx doesn't like citations which were not referenced from somewhere. And actually, I see no reason of mentioning this paper, we cannot mention everyone who worked with LSTMs.
Can you whether add some documentation concerning this paper or delete the reference?