matchms / ms2deepscore

Deep learning similarity measure for comparing MS/MS spectra with respect to their chemical similarity
Apache License 2.0
53 stars 24 forks source link

Saving model non-working #123

Closed jbcoffin closed 1 year ago

jbcoffin commented 1 year ago

Following MS2DeepScore_tutorial.ipynb, model.save(model_file_name) return ' AttributeError: 'Adam' object has no attribute 'weights' '. A file is generated but it is unusable, spectrum_binner and additional_input are missing.

justinjjvanderhooft commented 1 year ago

@florian-huber could this have to do with the recent matchms update, or with the recent ms2deepscore additions?

niekdejonge commented 1 year ago

I think this issue is not version dependent, but has to do with a small mistake in the tutorial. For the implementation in MS2Query this was solved and can be found here: https://github.com/iomega/ms2query/blob/main/ms2query/create_new_library/train_ms2deepscore.py Hope this helps.

niekdejonge commented 1 year ago

@florian-huber When trying to build a model I did run into the same error. It might be due to a new TensorFlow version since tensorflow version 2.11 the optimizers have been changed. I will look into this.

niekdejonge commented 1 year ago

Fixed with #129

florian-huber commented 1 year ago

@niekdejonge We should anyway reconsider the tensorflow versions we support. As far as I understood, >=2.11 will no longer support Windows (only WSL2) and contains some larger changes. I would probably keep it for now (as introduced in #129), but drop some older versions.

On the long run, we should probably look at Docker-based solutions for tensorflow. Those also make it easier to run code using local GPU.

florian-huber commented 1 year ago

I fixed the failing tensorflow test (reason was that a higher numpy version was needed). At the moment we test tensorflow 2.4, 2.6, 2.8 and the most recent version (2.10 to 2.12).

Should be fine for now. I would also keep the backwards checks unless it gets too much work. Mostly to make sure that models can be used and exchanged across multiple versions.