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 graphgym example for activation functions #5243

Merged
merged 9 commits into from
Aug 20, 2022

Conversation

M-Lampert
Copy link
Contributor

If you choose one of the given example activation functions (swish or lrelu_03) you get the following error:

Traceback (most recent call last):
  File "C:\Users\morit\workspace\pytorch_geometric\graphgym\main.py", line 42, in <module>
    model = create_model()
  File "C:\Users\morit\.conda\envs\test\lib\site-packages\torch_geometric\graphgym\model_builder.py", line 79, in create_model
    model = GraphGymModule(dim_in, dim_out, cfg)
  File "C:\Users\morit\.conda\envs\test\lib\site-packages\torch_geometric\graphgym\model_builder.py", line 20, in __init__
    self.model = network_dict[cfg.model.type](dim_in=dim_in,
  File "C:\Users\morit\.conda\envs\test\lib\site-packages\torch_geometric\graphgym\models\gnn.py", line 147, in __init__
    self.mp = GNNStage(dim_in=dim_in, dim_out=cfg.gnn.dim_inner,
  File "C:\Users\morit\.conda\envs\test\lib\site-packages\torch_geometric\graphgym\models\gnn.py", line 69, in __init__
    layer = GNNLayer(d_in, dim_out)
  File "C:\Users\morit\.conda\envs\test\lib\site-packages\torch_geometric\graphgym\models\gnn.py", line 27, in GNNLayer
    return GeneralLayer(
  File "C:\Users\morit\.conda\envs\test\lib\site-packages\torch_geometric\graphgym\models\layer.py", line 99, in __init__
    layer_wrapper.append(register.act_dict[layer_config.act]())
  File "C:\Users\morit\.conda\envs\test\lib\site-packages\torch\nn\modules\module.py", line 1130, in _call_impl
    return forward_call(*input, **kwargs)
TypeError: forward() missing 1 required positional argument: 'x'

This happens because the classes are initialized before registering and layer.py later tries to initialize them again.
My proposal: Use partial to specify the arguments without initializing the class.

@codecov
Copy link

codecov bot commented Aug 19, 2022

Codecov Report

Merging #5243 (a350d9a) into master (3d5f855) will decrease coverage by 0.11%.
The diff coverage is n/a.

@@            Coverage Diff             @@
##           master    #5243      +/-   ##
==========================================
- Coverage   83.15%   83.04%   -0.12%     
==========================================
  Files         337      337              
  Lines       18574    18574              
==========================================
- Hits        15445    15424      -21     
- Misses       3129     3150      +21     
Impacted Files Coverage Δ
torch_geometric/utils/scatter.py 42.50% <0.00%> (-52.50%) ⬇️

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

accidentally committed a suggestion to the branch
@Padarn Padarn enabled auto-merge (squash) August 20, 2022 11:56
@Padarn Padarn merged commit b69573e into pyg-team:master Aug 20, 2022
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.

3 participants