KANs example#20
Open
conordaly0 wants to merge 1 commit intomainfrom
Open
Conversation
bwdGitHub
reviewed
Apr 27, 2026
|
|
||
| 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)$. |
Collaborator
There was a problem hiding this comment.
The references 2 and 3 are mixed up - 2 is Chebyshev KANs and 3 is PINNs
bwdGitHub
reviewed
Apr 27, 2026
|
|
||
| # 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)\]. |
Collaborator
There was a problem hiding this comment.
The reference 2 should be 4 here
bwdGitHub
reviewed
Apr 27, 2026
|
|
||
| % Evaluate alpha for residual-based attention. | ||
| res = solverState.AdditionalLossFunctionOutputs{1}; | ||
| alpha = (1-eta).*alpha + eta.*(res./max(res)); |
Collaborator
There was a problem hiding this comment.
res should be abs(res) here (equation (3) here)
bwdGitHub
reviewed
Apr 27, 2026
| numOut = sz(1); | ||
| numIn = sz(2); | ||
|
|
||
| weights = randn(numOut,sz(2),"single") / numIn; |
Collaborator
There was a problem hiding this comment.
sz(2) can be numIn here.
bwdGitHub
reviewed
Apr 27, 2026
Collaborator
There was a problem hiding this comment.
May need to call the file README.md for it to render on GitHub directly. The top level readme could list this example too.
bwdGitHub
approved these changes
Apr 27, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adding Chebyshev basis KANs example