Skip to content

KANs example#20

Open
conordaly0 wants to merge 1 commit intomainfrom
kans
Open

KANs example#20
conordaly0 wants to merge 1 commit intomainfrom
kans

Conversation

@conordaly0
Copy link
Copy Markdown
Member

Adding Chebyshev basis KANs example

@conordaly0 conordaly0 requested a review from bwdGitHub April 22, 2026 08:34

A Kolmogorov\-Arnold neural network (KAN) is a type of neural network inspired by the Kolmogorov\-Arnold representation theorem \[[1](#M_050a)\]. It approximates multivariate functions using structured function compositions with fewer parameters. KANs are general\-purpose function approximators. This example uses a KAN to represent a physics\-informed neural network (PINN). A physics\-informed neural network is a neural network that incorporates physical laws into its structure and training process \[[2](#M_050a)\]. For example, you can train a PINN by incorporating the definition of a partial differential equation (PDE) that defines a physical system in the loss function.

This example trains a Chebyshev\-based KAN \[[3](#M_050a)\] that outputs the PDE solution $u(x,y)$ of the Helmholtz equation given the input $(x,y)$.
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The references 2 and 3 are mixed up - 2 is Chebyshev KANs and 3 is PINNs


# Define Chebyshev KAN Layer

The original KAN architecture in \[[1](#M_050a)\] uses B‑splines as the edge basis functions. There are several variants of the KAN architecture. This example uses a Chebyshev‑KAN variant, which was shown to perform well in a recent comparative study \[[2](#M_050a)\].
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The reference 2 should be 4 here


% Evaluate alpha for residual-based attention.
res = solverState.AdditionalLossFunctionOutputs{1};
alpha = (1-eta).*alpha + eta.*(res./max(res));
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

res should be abs(res) here (equation (3) here)

numOut = sz(1);
numIn = sz(2);

weights = randn(numOut,sz(2),"single") / numIn;
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sz(2) can be numIn here.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

May need to call the file README.md for it to render on GitHub directly. The top level readme could list this example too.

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

Successfully merging this pull request may close these issues.

2 participants