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

Allow interchangeability of KANLinear with nn.Linear #6

Merged
merged 1 commit into from
May 17, 2024

Conversation

akaashdash
Copy link
Contributor

Currently KANLinear strictly checks the dimensions are (batch_size, in_features). This does not allow compatibility with other input shapes where the feature sizes of the same. On the other hand, nn.Linear allows for any shape where the last dimension matches feature shape, eg: (, in_features), and it will reshape it to match and reshape back to the same (, out_features) on returning. Because of this difference, KANLinear and nn.Linear are currently not interchangeable, prevent people from swapping MLPs with KANs in existing code to explore differences in the two.

This change would allow for better shape compatibility, and therefore allow people to interchange KANLinear (or KAN) with nn.Linear layers.

@Blealtan
Copy link
Owner

Thank you for that! Just about to write that myself after reading the issue but before seeing your PR. And sorry for the delay. LGTM.

@Blealtan Blealtan merged commit 605b8c2 into Blealtan:master May 17, 2024
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