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

MCC value problem on Nucleotide Transformer #31

Closed
WeiminWu2000 opened this issue Nov 24, 2023 · 7 comments
Closed

MCC value problem on Nucleotide Transformer #31

WeiminWu2000 opened this issue Nov 24, 2023 · 7 comments

Comments

@WeiminWu2000
Copy link

I really appreciate your work, but when I train model on the downstream task Nucleotide Transformer, it shows that no MCC result returned, the details are as follows, could you please help me to solve it, thank you very mcuh!
Traceback (most recent call last):
File "/root/code/dnabert3/hyena-dna/train.py", line 692, in main
train(config)
File "/root/code/dnabert3/hyena-dna/train.py", line 673, in train
trainer.fit(model)
File "/root/miniconda3/envs/hyena-dna/lib/python3.8/site-packages/pytorch_lightning/trainer/trainer.py", line 603, in fit
call._call_and_handle_interrupt(
File "/root/miniconda3/envs/hyena-dna/lib/python3.8/site-packages/pytorch_lightning/trainer/call.py", line 38, in _call_and_handle_interrupt
return trainer_fn(*args, **kwargs)
File "/root/miniconda3/envs/hyena-dna/lib/python3.8/site-packages/pytorch_lightning/trainer/trainer.py", line 645, in _fit_impl
self._run(model, ckpt_path=self.ckpt_path)
File "/root/miniconda3/envs/hyena-dna/lib/python3.8/site-packages/pytorch_lightning/trainer/trainer.py", line 1098, in _run
results = self._run_stage()
File "/root/miniconda3/envs/hyena-dna/lib/python3.8/site-packages/pytorch_lightning/trainer/trainer.py", line 1177, in _run_stage
self._run_train()
File "/root/miniconda3/envs/hyena-dna/lib/python3.8/site-packages/pytorch_lightning/trainer/trainer.py", line 1200, in _run_train
self.fit_loop.run()
File "/root/miniconda3/envs/hyena-dna/lib/python3.8/site-packages/pytorch_lightning/loops/loop.py", line 200, in run
self.on_advance_end()
File "/root/miniconda3/envs/hyena-dna/lib/python3.8/site-packages/pytorch_lightning/loops/fit_loop.py", line 295, in on_advance_end
self.trainer._call_callback_hooks("on_train_epoch_end")
File "/root/miniconda3/envs/hyena-dna/lib/python3.8/site-packages/pytorch_lightning/trainer/trainer.py", line 1380, in _call_callback_hooks
fn(self, self.lightning_module, *args, **kwargs)
File "/root/miniconda3/envs/hyena-dna/lib/python3.8/site-packages/pytorch_lightning/callbacks/model_checkpoint.py", line 312, in on_train_epoch_end
self._save_topk_checkpoint(trainer, monitor_candidates)
File "/root/miniconda3/envs/hyena-dna/lib/python3.8/site-packages/pytorch_lightning/callbacks/model_checkpoint.py", line 367, in _save_topk_checkpoint
raise MisconfigurationException(m)
lightning_lite.utilities.exceptions.MisconfigurationException: ModelCheckpoint(monitor='val/mcc') could not find the monitored key in the returned metrics: ['trainer/loss', 'trainer/epoch', 'val/accuracy', 'val/loss', 'train/accuracy', 'train/loss', 'epoch', 'step']. HINT: Did you call log('val/mcc', value) in the LightningModule?

@exnx
Copy link
Collaborator

exnx commented Nov 24, 2023

  1. Are you running the docker image? or default repo code?

  2. It seems like a config changed and you are no longer passing the val/mcc metric to Lightning. You need this in your config somewhere, which is currently in the configs/pipeline/nucleotide_transformer.yaml.

train:
  monitor: val/${dataset.metric}
  mode: max

@exnx
Copy link
Collaborator

exnx commented Nov 24, 2023 via email

@WeiminWu2000
Copy link
Author

Thanks very much. I'll learn about it.

@exnx
Copy link
Collaborator

exnx commented Nov 25, 2023

Actually, what I showed above grabs the default metric set by the Nucleotide Transformer benchmarks, so it could be acc, or mcc. To force it show mcc, you can hardcode it, like this.

Note, this is what Lightning uses to save the best checkpoints, it "monitors" the val/mcc and will save the "max" or highest mcc ckpts.

train:
  monitor: val/mcc
  mode: max

@WeiminWu2000
Copy link
Author

Thanks for your reply! I'll try it!

@exnx
Copy link
Collaborator

exnx commented Nov 26, 2023

looks like that worked

@WeiminWu2000
Copy link
Author

Yes, thanks very much for you help!

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

No branches or pull requests

2 participants