pykan
pykan copied to clipboard
How to train other datasets with KAN
May I ask, if I want to train and test other datasets on KAN, how should I implement it?Can you provide code support?
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.