theislab / scgen

Single cell perturbation prediction
https://scgen.readthedocs.io
GNU General Public License v3.0
255 stars 51 forks source link

Question about saving the scgen model #51

Closed Lin-K76 closed 2 years ago

Lin-K76 commented 2 years ago

Hello,

I am trying to figure out how to save and load the models generated by scgen. I compared saving the model right after creating it using scgen.SCGEN(adata), to saving the model right after creating the model and saving once more after training the model. The resulting prediction seems very similar in both cases, so I am curious whether the model.train() function automatically saves the state of the model? If so, would I just be able to call scgen.SCGEN.load() to retrieve the trained model in both cases? Or am I doing something incorrectly?

Thank you!

adamgayoso commented 2 years ago

Can you provide a script of the things you've tried? The model should typically only be saved just after training, as before training, it's a random model with random state.

Lin-K76 commented 2 years ago

Hi, I'm really sorry haha, the mistake was on my end. I saved both before and after training, but ended up simply using the original model itself going forward, rather than loading and using the saved model. Loading the save of the model before training results in an error, whereas loading the save of the model after training does not. Thank you so much for clearing up the confusion! One last clarification then, for your example of perturbation prediction, should the save function in cell [7] be called after training in cell [8] for loading in the future? Thanks again!