Implementing One Class SVM in PyTorch

Is it possible to implement One Class SVM as a part of a Neural Network in PyTorch?

I am doing an experiment for my research on outlier detection and I need to implement One Class SVM as a layer and its objective function as apart of the main objective / loss function. I know I could use ScikitLearn and LibSVM for the same. But my experiment needs it to be a part of a neural network ensemble I am building. So the weights should be iteratively learnable with the other parameters of the NN.

Any help or pointers would be appreciated.

You could try to use e.g. nn.MultiLabelMarginLoss, which is the multi-classification hinge loss and create the desired targets for your “One Class SVM”.

1 Like