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

Cannot reproduce the results of hellokan.ipynb in the latest Python environment. #188

Open
tigran123 opened this issue May 14, 2024 · 1 comment

Comments

@tigran123
Copy link

tigran123 commented May 14, 2024

I have tried re-running all cells in the provided file hellokan.ipynb and starting from the cell [4] with the comment # train the model I get results, which are different from those shown in the notebook, namely I get train loss: 0.119 instead of 0.115, test loss: 0.125 instead of 0.121, reg: 28.1 instead of 25 and starting from this point everything is different. And, finally, the end result is not the nice $\exp(\sin(\pi x) + y^2)$, but a monstrous huge formula. So, my question is: perhaps some of the cells require running multiple times, e.g. maybe I should keep training the model in the cell [4] until I get the values matching in the notebook? Hmmm, in that case this should have been specified somewhere next to the cell or, better even, done programmatically inside the cell itself.

My environment: Python 3.12.3, matplotlib 3.8.4, numpy 1.26.4, scikit-learn 1.4.2, sympy 1.12 and, most notably, torch 2.3.0, so the versions of the packages are slightly newer and PyTorch is considerably newer, that what is specified in the file requirements.txt. Could this be the cause of the problem? Then we should debug and fix it as sooner or later someone will surely wish to use pykan with the latest Python packages...

I will try to reproduce the problem in a venv generated with the exact versions of the packages as per requirements.txt file.

UPDATE: Those old versions of the packages cannot be installed with Python 3.12.3, so I would have to downgrade Python itself to 3.9.7. I assumed that Python 3.12.3 would work, because the README.md said "3.9.7 or higher".

@tigran123
Copy link
Author

Just to update: if I rerun cell [4] (the first training), then I get the losses down to the values less than in the original and so after executing all the other cells I eventually get to the expected function in symbolic form. So, looks like with the latest versions of the packages the efficiency of training is somewhat lower and that is why the results were not reproducible if each cell is executed only once. I don't know if this issue should be closed or left for further investigation of which package is causing it. I would bet that it is PyTorch as it is the key package here and the version difference 2.2 vs 2.3 is rather substantial.

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

1 participant