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

Handling case where all molecules are invalid in property optimization #125

Merged
merged 2 commits into from
Oct 13, 2022
Merged

Handling case where all molecules are invalid in property optimization #125

merged 2 commits into from
Oct 13, 2022

Conversation

jannisborn
Copy link
Contributor

Currently (with the current code on master), if one runs the property optimization and the model produces only one unique molecule, we get this error:

torchdrug/torchdrug/tasks/generation.py", line 147, in reinforce_forward
    raise ValueError("Generation results collapse to singleton molecules")
ValueError: Generation results collapse to singleton molecules

Moreover, when we have only invalid molecules, we get another error:

torchdrug/torchdrug/tasks/generation.py", line 809, in reinforce_forward
    if graph.num_nodes.max() == 1:
RuntimeError: max(): Expected reduction dim to be specified for input.numel() == 0. Specify the reduction dim with the 'dim' argument.

Conceptually, the error is basically the same as reported in #83 (which was fixed in #84). But this time, the affected part is the property optimization, not in the training.

SOLUTION:
Basically, what I'm doing in this PR is imitating the two return variables of reinforce_forward whenever the number of generated molecules is 0 or 1.

Please have a look @KiddoZhu

@jannisborn
Copy link
Contributor Author

Hi @KiddoZhu, it would be great if you could have a look at the PR

@KiddoZhu KiddoZhu merged commit 28a677d into DeepGraphLearning:master Oct 13, 2022
@jannisborn jannisborn deleted the prop_opt_invalidity_handling branch November 23, 2022 10:07
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