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

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

Closed
binhnguyen7tiki opened this issue May 11, 2024 · 7 comments
Closed

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

binhnguyen7tiki opened this issue May 11, 2024 · 7 comments

Comments

@binhnguyen7tiki
Copy link

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

@hoangthangta
Copy link

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

@binhna
Copy link

binhna commented May 13, 2024

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>'

@hoangthangta
Copy link

Can you show me your code?

@Blealtan
Copy link
Owner

@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.

@hoangthangta
Copy link

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.

@Blealtan
Copy link
Owner

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

@binhna
Copy link

binhna commented May 22, 2024

@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.

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

4 participants