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

Add GCN-BMP #71

Merged
merged 23 commits into from
Feb 2, 2022
Merged

Add GCN-BMP #71

merged 23 commits into from
Feb 2, 2022

Conversation

mughetto
Copy link
Collaborator

@mughetto mughetto commented Feb 2, 2022

Summary

First draft of implementation for GCN-BMP. Closes Issue #21 .

  • Unit tests provided for these changes
  • Documentation and docstrings added for these changes

Changes

  • Add GCN-BMP model. Some parts might be moved in other files/projects:
    • Circular correlation function.
    • Highway update
    • Attention-based pooling/readout
  • Add example for the model.

Caveats

  • The number of relationships (for the Relational Conv layers) is configured in the model initialization. It should be done via some dataset-level constant.

Differences with the original paper

  • In the original GCN-BMP the feature vectors are initialized randomly based on the atomic number of the node. I couldn't find easily the implementation in their code so backed up on the features already provided in the PairedBatches.
  • Rel Conv layers are followed by a sigmoid activation before the Highway Update. This should only affect the stability.
  • Highway Update used is the one proposed in the original Highway network paper. Best for reusability imho and shouldn't affect the gating behavour.

Performance

Example's ROC AUC: 0.749128

@mughetto mughetto self-assigned this Feb 2, 2022
Copy link
Contributor

@benedekrozemberczki benedekrozemberczki left a comment

Choose a reason for hiding this comment

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

Generally looks good, typing is missing in certain places. The latest version of black should be used for linting. The auxiliary layers should be in the readme on some name space - also you should consider adding them to the README.

chemicalx/models/gcnbmp.py Outdated Show resolved Hide resolved
chemicalx/models/gcnbmp.py Outdated Show resolved Hide resolved
chemicalx/models/gcnbmp.py Outdated Show resolved Hide resolved
chemicalx/models/gcnbmp.py Outdated Show resolved Hide resolved
chemicalx/models/gcnbmp.py Show resolved Hide resolved
chemicalx/models/gcnbmp.py Outdated Show resolved Hide resolved
chemicalx/models/gcnbmp.py Outdated Show resolved Hide resolved
chemicalx/models/gcnbmp.py Show resolved Hide resolved
chemicalx/models/gcnbmp.py Outdated Show resolved Hide resolved
chemicalx/models/gcnbmp.py Outdated Show resolved Hide resolved
@cthoyt cthoyt added the model label Feb 2, 2022
chemicalx/models/gcnbmp.py Outdated Show resolved Hide resolved
chemicalx/models/gcnbmp.py Outdated Show resolved Hide resolved
examples/gcnbmp_examples.py Outdated Show resolved Hide resolved
@benedekrozemberczki benedekrozemberczki linked an issue Feb 2, 2022 that may be closed by this pull request
chemicalx/models/gcnbmp.py Outdated Show resolved Hide resolved
@benedekrozemberczki
Copy link
Contributor

@cthoyt I overtook this.

@cthoyt
Copy link
Contributor

cthoyt commented Feb 2, 2022

@benedekrozemberczki let me know when you're done and I'll take a final pass

@benedekrozemberczki benedekrozemberczki marked this pull request as ready for review February 2, 2022 15:59
@benedekrozemberczki
Copy link
Contributor

@cthoyt Ready for review.

@codecov-commenter
Copy link

Codecov Report

Merging #71 (42eadbf) into main (2fb3421) will increase coverage by 0.35%.
The diff coverage is 97.87%.

Impacted file tree graph

@@            Coverage Diff             @@
##             main      #71      +/-   ##
==========================================
+ Coverage   94.01%   94.36%   +0.35%     
==========================================
  Files          29       29              
  Lines         869      959      +90     
==========================================
+ Hits          817      905      +88     
- Misses         52       54       +2     
Impacted Files Coverage Δ
chemicalx/models/gcnbmp.py 97.61% <97.59%> (-2.39%) ⬇️
tests/unit/test_models.py 100.00% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 2fb3421...42eadbf. Read the comment docs.

@benedekrozemberczki benedekrozemberczki merged commit 125b6fb into main Feb 2, 2022
@benedekrozemberczki benedekrozemberczki deleted the 21-add-gcn-bmp branch February 2, 2022 16:16
andriy-nikolov pushed a commit to andriy-nikolov/chemicalx that referenced this pull request Feb 3, 2022
* linting

* GCNBMP Scatter Reduction fix

* Using Rel Conv Layers instead of RGCN Model (avoid unecessary sum readouts)

* Added docstrings and fixed highway update implementation

* Make number of relationship configurable

* little help of black for linting

* Cleaning upuseless imports

* Sharing attention between right and left side

* Adding reference to GCNBMP docstring

* Type hinting everything

* Fixing docstring in example

* - Removing type hints in docstrings as they were added to signatures
- Chunked iteration of the BMP backbone for better readability

* Ading more-itertools as a dependecy

* Using pairwise for encoder construction

* Adding missing docstrings

* Fixing linting and precommit hook

* Fixing the citation back to what is in main

* Tests,formatting,example

* Tests,formatting,example

* GCNBMP

* Cleanup

Co-authored-by: kcvc236 <kcvc236@seskscpg057.prim.scp>
Co-authored-by: Rozemberczki <kmdb028@astrazeneca.net>
Co-authored-by: kcvc236 <kcvc236@seskscpg059.prim.scp>
Co-authored-by: Charles Tapley Hoyt <cthoyt@gmail.com>
benedekrozemberczki added a commit that referenced this pull request Feb 3, 2022
* CASTER layer implementation

- only supervised training stage
- input dimensionality assumed to be correct

* Apply black and reorganize

* Move loss into its own module

* Update caster.py

* Reduce diff on citation

* Implement DeepDrug model (#68)

* WIP: model forward pass works, not tested

* added dropout and batch norm

* WIP: made DeepDrug example, not tested

* moved to using layers only, not GCN torchdrug model

* docstring

* added dropout and made context feats optional

* added DeepDrug unit test

* deepdrug self attribute fix

* docstring update

* unpack method update (when no context feats used)

* isort

* fixed test setting (context_channels)

* fixed testing without context

* black

* RST fix

* RST fix

* more pythonic loop + swap i to _

* removed context feat support in DeepDrug

* removed context handling from testing DeepDrug

* fixed examples DeepDrug, no context handling, decreased epochs 100->20

* removed unused import

* used a wrapper for calling the same layers on pairs of batches

* used a wrapper for calling the same layers on pairs of batches

* docstring fix

* Abstract process applied to left and right sides

* Apply black

* Cleanup

Co-authored-by: Charles Tapley Hoyt <cthoyt@gmail.com>

* Add GCN-BMP (#71)

* linting

* GCNBMP Scatter Reduction fix

* Using Rel Conv Layers instead of RGCN Model (avoid unecessary sum readouts)

* Added docstrings and fixed highway update implementation

* Make number of relationship configurable

* little help of black for linting

* Cleaning upuseless imports

* Sharing attention between right and left side

* Adding reference to GCNBMP docstring

* Type hinting everything

* Fixing docstring in example

* - Removing type hints in docstrings as they were added to signatures
- Chunked iteration of the BMP backbone for better readability

* Ading more-itertools as a dependecy

* Using pairwise for encoder construction

* Adding missing docstrings

* Fixing linting and precommit hook

* Fixing the citation back to what is in main

* Tests,formatting,example

* Tests,formatting,example

* GCNBMP

* Cleanup

Co-authored-by: kcvc236 <kcvc236@seskscpg057.prim.scp>
Co-authored-by: Rozemberczki <kmdb028@astrazeneca.net>
Co-authored-by: kcvc236 <kcvc236@seskscpg059.prim.scp>
Co-authored-by: Charles Tapley Hoyt <cthoyt@gmail.com>

* Implement DeepDDI model (#63)

* update: Add deepddi model

* update: Add deepddi examples

* update: Add deepddi test case

* Style: deepddi model

* Style: deepddi model

* Style: deepddi_examples.py

* Update deepddi.py

* Update deepddi.py

Co-authored-by: Charles Tapley Hoyt <cthoyt@gmail.com>

* CASTER review fixes

* flake8 fixes

* CASTER: typing fix

Co-authored-by: Andriy Nikolov <kgsq682@astrazeneca.net>
Co-authored-by: Charles Tapley Hoyt <cthoyt@gmail.com>
Co-authored-by: Piotr Grabowski <3966940+kajocina@users.noreply.github.com>
Co-authored-by: Michaël Ughetto <michael.ughetto@astrazeneca.com>
Co-authored-by: kcvc236 <kcvc236@seskscpg057.prim.scp>
Co-authored-by: Rozemberczki <kmdb028@astrazeneca.net>
Co-authored-by: kcvc236 <kcvc236@seskscpg059.prim.scp>
Co-authored-by: walter <32014404+hzcheney@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add the GCNBMP model
4 participants