pykan icon indicating copy to clipboard operation
pykan copied to clipboard

Something wrong after model.fix_symbolic()

Open GuoMinghui07 opened this issue 7 months ago • 4 comments

I encountered a RuntimeError while performing symbolic regression. The error message indicates that one of the arguments has an illegal value. Below is the detailed error message and my code.

Here is the code I used for symbolic regression:

from kan import *
f = lambda x: torch.cosh(3*x[:, [0]]**2 + 2*x[:, [0]] + x[:, [1]])
dataset = create_dataset(f, n_var=2, ranges=[-1,1], train_num=1000)
model = MultKAN(width=[2,1,1], base_fun='identity', auto_save=True,seed=4)
model.fit(dataset, steps=100)
model.get_act(dataset)
model.plot()
截屏2024-07-17 11 47 52

I found the result of fixing (1,0,0) with exp, r2=0.9992531538009644, c=2 was incorrect then I fixed it by using:

model.unfix_symbolic(1,0,0)
model.fix_symbolic(1,0,0,'cosh')
model.fit(dataset, steps=50)

and there was an error similar to #287

截屏2024-07-17 11 53 33

GuoMinghui07 avatar Jul 17 '24 03:07 GuoMinghui07