-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Restore compatibility with models handling fewer tokens (#104)
This PR addresses #102. It also fixes an issue where DASM model output dimension grew with the number of amino acid tokens, instead of staying fixed at `20`.
- Loading branch information
Showing
22 changed files
with
140 additions
and
44 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
encoder_class: PlaceholderEncoder | ||
encoder_parameters: {} | ||
model_class: TransformerBinarySelectionModelWiggleAct | ||
model_hyperparameters: | ||
d_model_per_head: 4 | ||
dim_feedforward: 64 | ||
dropout_prob: 0.1 | ||
layer_count: 3 | ||
nhead: 4 | ||
output_dim: 20 | ||
serialization_version: 0 | ||
training_hyperparameters: | ||
batch_size: 1024 | ||
learning_rate: 0.001 | ||
min_learning_rate: 1.0e-06 | ||
optimizer_name: RMSprop | ||
weight_decay: 1.0e-06 |
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
encoder_class: PlaceholderEncoder | ||
encoder_parameters: {} | ||
model_class: TransformerBinarySelectionModelWiggleAct | ||
model_hyperparameters: | ||
d_model_per_head: 4 | ||
dim_feedforward: 64 | ||
dropout_prob: 0.1 | ||
layer_count: 3 | ||
nhead: 4 | ||
output_dim: 1 | ||
serialization_version: 0 | ||
training_hyperparameters: | ||
batch_size: 1024 | ||
learning_rate: 0.001 | ||
min_learning_rate: 1.0e-06 | ||
optimizer_name: RMSprop | ||
weight_decay: 1.0e-06 |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import torch | ||
|
||
from netam.framework import load_crepe | ||
from netam.sequences import set_wt_to_nan | ||
|
||
|
||
# The outputs used for this test are produced by running | ||
# `test_backward_compat_copy.py` on the wd-old-model-runner branch. | ||
# This is to ensure that we can still load older crepes, even if we change the | ||
# dimensions of model layers, as we did with the Embedding layer in | ||
# https://github.com/matsengrp/netam/pull/92. | ||
def test_old_model_outputs(): | ||
example_seq = "QVQLVESGGGVVQPGRSLRLSCAASGFTFSSSGMHWVRQAPGKGLEWVAVIWYDGSNKYYADSVKGRFTISRDNSKNTVYLQMNSLRAEDTAVYYCAREGHSNYPYYYYYMDVWGKGTTVTVSS" | ||
dasm_crepe = load_crepe("tests/old_models/dasm_13k-v1jaffe+v1tang-joint") | ||
dnsm_crepe = load_crepe("tests/old_models/dnsm_13k-v1jaffe+v1tang-joint") | ||
|
||
dasm_vals = torch.nan_to_num( | ||
set_wt_to_nan( | ||
torch.load("tests/old_models/dasm_output", weights_only=True), example_seq | ||
), | ||
0.0, | ||
) | ||
dnsm_vals = torch.load("tests/old_models/dnsm_output", weights_only=True) | ||
|
||
dasm_result = torch.nan_to_num(dasm_crepe([example_seq])[0], 0.0) | ||
dnsm_result = dnsm_crepe([example_seq])[0] | ||
assert torch.allclose(dasm_result, dasm_vals) | ||
assert torch.allclose(dnsm_result, dnsm_vals) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.