Noble-Lab / casanovo

De Novo Mass Spectrometry Peptide Sequencing with a Transformer Model
https://casanovo.readthedocs.io
Apache License 2.0
102 stars 37 forks source link

ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all() #329

Closed dadadalizi146 closed 4 months ago

dadadalizi146 commented 4 months ago

when using casanovo to sequence new spectra with boh top_match = 10 and n_beams = 10, I encounter this error when the sequencing progress reached 53%:

runpy.py 197 _run_module_as_main
return _run_code(code, main_globals, None,

runpy.py 87 _run_code
exec(code, run_globals)

__main__.py 7 <module>
sys.exit(main())

rich_command.py 367 __call__
return super().__call__(*args, **kwargs)

core.py 1157 __call__
return self.main(*args, **kwargs)

rich_command.py 152 main
rv = self.invoke(ctx)

core.py 1688 invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))

core.py 1434 invoke
return ctx.invoke(self.callback, **ctx.params)

core.py 783 invoke
return __callback(*args, **kwargs)

casanovo.py 143 sequence
runner.predict(peak_path, output)

model_runner.py 164 predict
self.trainer.predict(self.model, self.loaders.test_dataloader())

trainer.py 864 predict
return call._call_and_handle_interrupt(

call.py 44 _call_and_handle_interrupt
return trainer_fn(*args, **kwargs)

trainer.py 903 _predict_impl
results = self._run(model, ckpt_path=ckpt_path)

trainer.py 987 _run
results = self._run_stage()

trainer.py 1028 _run_stage
return self.predict_loop.run()

utilities.py 182 _decorator
return loop_run(self, *args, **kwargs)

prediction_loop.py 124 run
self._predict_step(batch, batch_idx, dataloader_idx, dataloader_iter)

prediction_loop.py 253 _predict_step
predictions = call._call_strategy_hook(trainer, "predict_step", *step_args)

call.py 309 _call_strategy_hook
output = fn(*args, **kwargs)

strategy.py 438 predict_step
return self.lightning_module.predict_step(*args, **kwargs)

model.py 820 predict_step
self.forward(batch[0], batch[1]),

model.py 200 forward
return self.beam_search_decode(

model.py 301 beam_search_decode
return list(self._get_top_peptide(pred_cache))

model.py 666 _get_top_peptide
for pep_score, aa_scores, pred_tokens in heapq.nlargest(

heapq.py 541 nlargest
return sorted(iterable, key=key, reverse=True)[:n]

ValueError:
The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()
Predicting DataLoader 0:  54%|█████▍    | 520/955 [13:30:41<11:18:10,  0.01it/s]
dadadalizi146 commented 4 months ago

The version info is:

Casanovo: 4.1.0 The operating system is Windows11 (using a 3090 GPU).

bittremieux commented 4 months ago

Seems similar to #271, although maybe in a slightly different part of the code. Thanks for reporting the bug, we'll have a look at it.

bittremieux commented 4 months ago

This was indeed the same bug as #271, it just wasn't integrated in a new version yet.

Casanovo v4.2.0 has now been released and is available from PyPI. Please upgrade and then the bug should be fixed.