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

Implement DeepDDI model #63

Merged
merged 9 commits into from
Feb 2, 2022
Merged

Conversation

hzcheney
Copy link
Contributor

@hzcheney hzcheney commented Jan 28, 2022

Closes #2

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

Changes

  • add DeepDDI model
  • add DeepDDI examples
  • add DeepDDI testcase

chemicalx/models/deepddi.py Outdated Show resolved Hide resolved
chemicalx/models/deepddi.py Outdated Show resolved Hide resolved
@cthoyt
Copy link
Contributor

cthoyt commented Jan 28, 2022

Please run tox locally to make sure that all tests are passing before we give a further review

@codecov-commenter
Copy link

codecov-commenter commented Jan 28, 2022

Codecov Report

Merging #63 (c16f927) into main (5449f96) will increase coverage by 0.06%.
The diff coverage is 96.66%.

Impacted file tree graph

@@            Coverage Diff             @@
##             main      #63      +/-   ##
==========================================
+ Coverage   93.87%   93.93%   +0.06%     
==========================================
  Files          29       29              
  Lines         832      858      +26     
==========================================
+ Hits          781      806      +25     
- Misses         51       52       +1     
Impacted Files Coverage Δ
chemicalx/models/deepddi.py 95.00% <94.73%> (-5.00%) ⬇️
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 5449f96...c16f927. Read the comment docs.

@benedekrozemberczki
Copy link
Contributor

Hi there @hzcheney, do you plan to update this PR?

@hzcheney
Copy link
Contributor Author

Hi there @hzcheney, do you plan to update this PR?

Yes! I will update this PR ASAP.

@benedekrozemberczki
Copy link
Contributor

The formatting still fails.

@benedekrozemberczki
Copy link
Contributor

These are the errors:

./tests/unit/test_models.py:61:59: BLK100 Black would make changes.
./examples/deepddi_examples.py:22:10: BLK100 Black would make changes.
./examples/epgcnds_examples.py:15:55: BLK100 Black would make changes.

@hzcheney
Copy link
Contributor Author

I am working on it, it's weird that I run tox locally well.

@hzcheney
Copy link
Contributor Author

hzcheney commented Jan 30, 2022

Please help! I have no idea why these errors still happened:

./tests/unit/test_models.py:61:59: BLK100 Black would make changes.
./examples/epgcnds_examples.py:15:55: BLK100 Black would make changes.

Even I did not change the epgcnds_examples.py file.
:-)

@cthoyt
Copy link
Contributor

cthoyt commented Jan 30, 2022

Yesterday, black made a new release that will cause some changes. The options are either:

  1. Wait for a new PR where I make these changes
  2. Pin black (terrible idea! Do not do this!)
  3. Commit the changes black makes when you run tox

@hzcheney
Copy link
Contributor Author

Yesterday, black made a new release that will cause some changes. The options are either:

  1. Wait for a new PR where I make these changes
  2. Pin black (terrible idea! Do not do this!)
  3. Commit the changes black makes when you run tox

Thank you! It's clear to me now.

chemicalx/models/deepddi.py Outdated Show resolved Hide resolved
@benedekrozemberczki
Copy link
Contributor

Hi there @hzcheney, I suggest updating black on your side. Do you want to finish the PR or we can overtake from you?

@cthoyt cthoyt added the model label Feb 1, 2022
@cthoyt cthoyt changed the title Implementation of DeepDDI model Implement DeepDDI model Feb 1, 2022
@cthoyt cthoyt 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.

@cthoyt can you make these changes?

__all__ = [
"DeepDDI",
]


class DeepDDI(UnimplementedModel):
class DeepDDI(Model):
"""An implementation of the DeepDDI model.
Copy link
Contributor

Choose a reason for hiding this comment

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

Please change the docstring to include paper reference.

*,
drug_channels: int,
hidden_channels: int = 2048,
hidden_layers_num: int = 9,
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we setup a smaller number of layers and lower hidden channel number?

Copy link
Contributor

Choose a reason for hiding this comment

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

@cthoyt can we have 4 layer with 32 hidden channels?


super(DeepDDI, self).__init__()
assert hidden_layers_num > 1
dnn = []
Copy link
Contributor

Choose a reason for hiding this comment

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

I would strongly suggest using a fixed number of layers. E.g. 3 or 4.

input_feature = torch.cat([drug_features_left, drug_features_right], 1)
hidden = self.dnn(input_feature)
return hidden

Copy link
Contributor

Choose a reason for hiding this comment

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

Remove spaces. The PR does not follow linting. Please use black to format your code. When you push again you can test it on the repo.

@@ -165,8 +165,22 @@ def test_ssiddi(self):

def test_deepddi(self):
"""Test DeepDDI."""
model = DeepDDI(x=2)
assert model.x == 2
Copy link
Contributor

Choose a reason for hiding this comment

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

Create a test also for hidden_layer_num=1.

@benedekrozemberczki benedekrozemberczki merged commit 424b440 into AstraZeneca:main Feb 2, 2022
andriy-nikolov pushed a commit to andriy-nikolov/chemicalx that referenced this pull request Feb 3, 2022
* 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>
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>
@hzcheney hzcheney deleted the issue2 branch February 4, 2022 09:05
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 DeepDDI model
4 participants