Skip to content

Commit 6dee14a

Browse files
Minor bug fixes
1 parent f89cbe9 commit 6dee14a

5 files changed

Lines changed: 59 additions & 5 deletions

File tree

configs/lgi/all_cold_glycan.yaml

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
seed: 42
2+
# root_dir: /scratch/SCRATCH_SAS/roman/Gothenburg/GIFFLAR/data_new_256
3+
# logs_dir: /scratch/SCRATCH_SAS/roman/Gothenburg/GIFFLAR/logs_new_256
4+
# origin: /scratch/SCRATCH_SAS/roman/Gothenburg/GIFFLAR/data_new_256/lgi_random_small.csv
5+
root_dir: /scratch/data_new_256
6+
logs_dir: /scratch/logs_new_256
7+
origin: /scratch/data_new_256/lgi_cold_glycan_150k.csv
8+
pre-transforms:
9+
GIFFLARTransform:
10+
GNNGLYTransform:
11+
ECFPTransform:
12+
SweetNetTransform:
13+
model:
14+
glycan_encoder:
15+
- name: mlp
16+
feat_dim: 1024
17+
hidden_dim: 1024
18+
output_dim: 1024
19+
num_layers: 1
20+
- name: sweetnet
21+
feat_dim: 128
22+
hidden_dim: 256
23+
num_layers: 16
24+
suffix:
25+
- name: gnngly
26+
feat_dim: 128
27+
hidden_dim: 256
28+
num_layers: 8
29+
suffix:
30+
# - name: rgcn
31+
# feat_dim: 128
32+
# hidden_dim: 256
33+
# num_layers: 8
34+
# suffix:
35+
- name: gifflar
36+
feat_dim: 128
37+
hidden_dim: 256
38+
num_layers: 8
39+
pooling: global_mean
40+
suffix:
41+
lectin_encoder:
42+
- name: ESM
43+
layer_num: 33
44+
batch_size: 256
45+
epochs: 25
46+
learning_rate: 0.001
47+
optimizer: Adam

experiments/lectinoracle.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
from glycowork.ml.models import prep_model
88

99
from gifflar.data.modules import LGI_GDM
10-
from gifflar.data.datasets import GlycanOnDiskDataset
10+
from gifflar.data.datasets_lgi import GlycanOnDiskDataset
1111
from experiments.protein_encoding import ENCODER_MAP
1212
from gifflar.model.utils import LectinStorage
1313

experiments/lgi_model.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99
from experiments.protein_encoding import ENCODER_MAP, EMBED_SIZES
1010
from gifflar.data.hetero import HeteroDataBatch
1111
from gifflar.model.base import GlycanGIN
12+
from gifflar.model.baselines.gnngly import GNNGLY
13+
from gifflar.model.baselines.mlp import MLP
1214
from gifflar.model.baselines.sweetnet import SweetNetLightning
1315
from gifflar.model.downstream import DownstreamGGIN
1416
from gifflar.model.glylm import GlycanLM
@@ -19,6 +21,8 @@
1921

2022
GLYCAN_ENCODERS = {
2123
"gifflar": DownstreamGGIN,
24+
"gnngly": GNNGLY,
25+
"mlp": MLP,
2226
"sweetnet": SweetNetLightning,
2327
"glylm": GlycanLM,
2428
}
@@ -110,7 +114,7 @@ def shared_step(self, batch: HeteroData, stage: str, batch_idx: int = 0, dataloa
110114
"""
111115
fwd_dict = self(batch)
112116
fwd_dict["labels"] = batch["y"]
113-
fwd_dict["preds"] = fwd_dict["preds"].reshape(-1)
117+
fwd_dict["preds"] = fwd_dict["preds"].reshape(-1).float()
114118
if dataloader_idx == 0:
115119
fwd_dict["loss"] = self.loss(fwd_dict["preds"], fwd_dict["labels"])
116120
self.metrics[stage].update(fwd_dict["preds"], fwd_dict["labels"])

experiments/train_lgi.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ def unfold_config(config: dict):
5454

5555

5656
def train(contrastive: bool = False, ckpt_file: Path | None = None, **kwargs):
57-
kwargs["pre-transforms"] = {"GIFFLARTransform": "", "SweetNetTransform": ""}
57+
# kwargs["pre-transforms"] = {"GIFFLARTransform": "", "SweetNetTransform": ""}
5858
kwargs["hash"] = hash_dict(kwargs["pre-transforms"])
5959
seed_everything(kwargs["seed"])
6060

ext_baselines/sweettalk.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,9 @@ def main(base: Path, task: str):
171171
elif task == "Taxonomy_Kingdom":
172172
config = {"name": "Taxonomy_Kingdom", "task": "classification", "num_classes": 13}
173173
metrics = get_metrics("multilabel", n_outputs=13)
174+
elif task == "spectrum":
175+
config = {"name": "Spectrum", "task": "regression", "num_classes": 2048}
176+
metrics = get_metrics("regression", n_outputs=2048)
174177
else:
175178
raise ValueError(f"Unknown task {task}")
176179

@@ -202,7 +205,7 @@ def main(base: Path, task: str):
202205
scheduler,
203206
metrics,
204207
datamodule,
205-
num_epochs=100,
208+
num_epochs=2,
206209
padding=False
207210
)
208211
torch.save(model.state_dict(), version / "model.pth")
@@ -211,6 +214,6 @@ def main(base: Path, task: str):
211214
if __name__ == "__main__":
212215
parser = argparse.ArgumentParser()
213216
parser.add_argument("--base", type=Path, required=True)
214-
parser.add_argument("--task", type=str, required=True, choices=["glycosylation", "tissue", "Taxonomy_Kingdom"])
217+
parser.add_argument("--task", type=str, required=True, choices=["glycosylation", "tissue", "Taxonomy_Kingdom", "spectrum"])
215218
args = parser.parse_args()
216219
main(args.base, args.task)

0 commit comments

Comments
 (0)