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

Bugfix for str_to_net(...) #12

Merged
merged 1 commit into from
Aug 31, 2022
Merged

Bugfix for str_to_net(...) #12

merged 1 commit into from
Aug 31, 2022

Conversation

engintoklu
Copy link
Collaborator

When extracting the child modules of an nn.Sequential instance, the parser used by str_to_net(...) was traversing in a recursive manner (which is undesired). The newly proposed code here uses the iterable nature of nn.Sequential to correctly extract the child modules of nn.Sequential.

When working with modules which are composed of other modules, str_to_net(...) was erroneously adding the children modules twice into the resulting nn.Sequential. For example, when the network string contains RecurrentNet (RecurrentNet being a module that wraps a child RNN module) the resulting nn.Sequential was ending up with the RecurrentNet and its child RNN appended erroneously. This proposal aims to fix this issue.

When extracting the child modules of an `nn.Sequential` instance, the parser used by `str_to_net(...)` was traversing in a recursive manner (which is undesired). The newly proposed code here uses the iterable nature of `nn.Sequential` to correctly extract the child modules of `nn.Sequential`.

When working with modules which are composed of other modules, `str_to_net(...)` was erroneously adding the children modules twice into the resulting `nn.Sequential`. For example, when the network string contains `RecurrentNet` (`RecurrentNet` being a module that wraps a child `RNN` module) the resulting `nn.Sequential` was ending up with the `RecurrentNet` _and_ its child `RNN` appended erroneously. This proposal aims to fix this issue.
@engintoklu engintoklu self-assigned this Aug 29, 2022
@engintoklu engintoklu added the bug Something isn't working label Aug 29, 2022
Copy link
Collaborator

@NaturalGradient NaturalGradient left a comment

Choose a reason for hiding this comment

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

I have checked and this removes the crash when using str_to_net with stateful modules such as RecurrentNet as the policy in the examples/notebooks/Gym_Experiments_with_PGPE_and_CoSyNE.ipynb example notebook.

@Higgcz Higgcz merged commit 6efb628 into master Aug 31, 2022
@flukeskywalker flukeskywalker deleted the bugfix/str-to-net branch September 7, 2022 22:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants