efficient-kan icon indicating copy to clipboard operation
efficient-kan copied to clipboard

Is there anyway that I can save the model for later use

Open binhnguyen7tiki opened this issue 9 months ago • 4 comments

Hi, thank you for your work. As for the title, I would like some ways to save the model for inference. I have tried pickle dump but it does not work. Thanks

binhnguyen7tiki avatar May 11 '24 09:05 binhnguyen7tiki

You can use: torch.save(model, your_model_path)

Then load it to do inference: model = torch.load(model_path) model.eval()

For more information: https://pytorch.org/tutorials/beginner/saving_loading_models.html

hoangthangta avatar May 11 '24 16:05 hoangthangta

Have you tried this? Not work for me. Because the torch saving seems to use the pickle too. AttributeError: Can't pickle local object 'Symbolic_KANLayer.__init__.<locals>.<listcomp>.<listcomp>.<lambda>'

binhna avatar May 13 '24 04:05 binhna

Can you show me your code?

hoangthangta avatar May 13 '24 05:05 hoangthangta

@binhnguyen7tiki Please post the full error message.

@binhna I don't think my implementation includes Symbolic_KANLayer. It should be part of the official implementation.

BTW, it seems the two accounts are the same person? Correct me if I'm wrong.

Blealtan avatar May 17 '24 18:05 Blealtan

Have you tried this? Not work for me. Because the torch saving seems to use the pickle too. AttributeError: Can't pickle local object 'Symbolic_KANLayer.__init__.<locals>.<listcomp>.<listcomp>.<lambda>'

Do you use the original KAN (https://github.com/KindXiaoming/pykan) for training your model? Then, ask them there better.

hoangthangta avatar May 20 '24 03:05 hoangthangta

Seemingly unrelated to this repo. Close for now and if I'm wrong I'll reopen it.

Blealtan avatar May 20 '24 12:05 Blealtan

@Blealtan @hoangthangta sorry for the late reply, and yes, I checked the code again and it was the original KAN indeed. I switched to efficient-kan now and everything seems to be fine. Thank you guys for your help. PS: @Blealtan correct! it was the same guy, I accidentally used my work account in the first place.

binhna avatar May 22 '24 02:05 binhna