KindXiaoming / pykan

Kolmogorov Arnold Networks
MIT License
15.12k stars 1.4k forks source link

problem of auto_symbolic(lib=lib) #480

Open niuniu666-ignore opened 1 month ago

niuniu666-ignore commented 1 month ago

I use model.prune() to prune my KAN network. After that, I use model.auto_symbolic(lib=lib) to get a formula.

The problem is that when I use lib = ['x'] to get a linear formula, KAN is work. However, when I change the lib = ['x'] to lib = ['x', 'x^2', 'x^3', 'x^4', 'exp', 'log', 'sqrt', 'tanh', 'sin', 'abs', 'cosh'], the system reports an error: ZeroDivisionError: integer division or modulo by zero. Sometimes, when I change the initial seed, KAN will work and give me a complex formula. For example, I change KAN(width=[4, 4, 4, 1], grid = 20, k=3, seed=0) to KAN(width=[4, 4, 4, 1], grid = 20, k=3, seed=100), the code will run successful, but sometimes, whatever I change the initial seed, the system will always report the error, which I mentioned before.

I cannot sovle this problem.