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

Hidden states in TermEncoder accessed before initialized #17

Closed
vrjmath opened this issue Dec 30, 2020 · 2 comments
Closed

Hidden states in TermEncoder accessed before initialized #17

vrjmath opened this issue Dec 30, 2020 · 2 comments
Labels
question Further information is requested

Comments

@vrjmath
Copy link

vrjmath commented Dec 30, 2020

In the TermEncoder class, the hidden_states dictionary is declared at line 148
hidden_states = {} # node -> hidden state,
accessed at line 168
h = hidden_states[c],
and initialized at line 185
hidden_states[node] = hiddens[i].
I seem to be getting at error because hidden_states is empty when the code tries to access it at line 168.

@yangky11
Copy link
Collaborator

Thanks for your interest in our work!

In each iteration, we access the nodes of a specific height. And we iterate from height 0 to 1, 2, ... etc.

for height in sorted(height2nodes.keys()):

Nodes with height 0 are leaf nodes. They do not have children. So this inner loop will not be executed in the first iteration of the outer loop:

'constructor_rel',

Therefore, hidden_states should have been initialized when it is accessed. For each node, we always access the hidden_states of its children, which are already initialized because we go from bottom to up.

Feel free to let me know if you have further questions.

@vrjmath
Copy link
Author

vrjmath commented Dec 30, 2020

Perfect, thanks!

@vrjmath vrjmath closed this as completed Dec 30, 2020
@yangky11 yangky11 added the question Further information is requested label Jan 4, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants