pykan icon indicating copy to clipboard operation
pykan copied to clipboard

How to train other datasets with KAN

Open hexincheng98 opened this issue 9 months ago • 1 comments

May I ask, if I want to train and test other datasets on KAN, how should I implement it?Can you provide code support?

hexincheng98 avatar May 09 '24 13:05 hexincheng98

To use KANs in other datasets, you can use the KAN model like a layer. The forward method is defined within the KAN module, so you can pass the input through the KAN layer to get the output you specify.

However, values such as l1 regulation may require additional work as you need to add them manually. In my case, I used sklearn's "make_classification" dataset to train binary classification using 8 dimensions of data, and after configuring the dataset appropriately, I used the "class Model(nn.Module): def init(self): super(Model, self).init() self.KAN = KAN([PCA_dim,PCA_dim*2-1,1]) def forward(self, x): output = self.KAN(x) output = nn.Sigmoid()(output) output = torch.squeeze(output) return output" After constructing these models, I put the parameters into the optimizer and trained it, and the training went fine.

pop756 avatar May 10 '24 05:05 pop756