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

Fix mask for RNN hidden states reset #28

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

kaixi287
Copy link

@kaixi287 kaixi287 commented Jun 13, 2024

This PR updates the reset function to convert the dones mask to a boolean mask before applying it to reset hidden states. Previously, the function used a 0/1 mask directly, which selected the first and second set of indices in the last but one dimension, rather than resetting the hidden states at the desired positions indicated by 1 in the mask. By converting the dones mask to a boolean mask, we ensure that the hidden states are correctly reset at the specified positions.

@kaixi287 kaixi287 changed the title Change dones to bool mask for hidden states reset Fix mask for RNN hidden states reset Jun 13, 2024
@@ -92,6 +92,8 @@ def forward(self, input, masks=None, hidden_states=None):
return out

def reset(self, dones=None):
if dones is not None:
dones = dones.bool()
Copy link
Collaborator

Choose a reason for hiding this comment

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

what happens if dones is None?

Copy link
Author

@kaixi287 kaixi287 Jun 17, 2024

Choose a reason for hiding this comment

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

All elements of hidden_state will be set to 0.0.

@kaixi287 kaixi287 requested a review from nikitardn June 17, 2024 11:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants