Skip to content

This implements a linear SVM using fully-connected layer and hinge loss using PyTorch.

Notifications You must be signed in to change notification settings

nathanlem1/SVM_PyTorch

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

24 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

This repository implements a linear Support Vector Machine (SVM) using PyTorch. The linear SVM can be implemented using fully connected layer and multi-class classification hinge loss in PyTorch. We also include a logistic regression which uses cross-entropy loss which internally computes softmax. In this implementation, we also include regularization techniques such as L1 (LASSO - Least Absolute Shrinkage and Selection Operator) which leads to sparsity, L2 (Ridge) and Elastic Net (combination of L1 and L2) based on Lecture note.

We think this repository can be used as a complementary to the pytorch-tutorial which implements traditional supervised machine learning algorithms such as linear regression, logistic regression and feedforward neural network in addition to some advanced useful deep learning methods. In this repository, we implemented the linear SVM. It is also recommended to look into the Official Pytorch Tutorial to start with if you are a beginner.

We also include the performance of the learned model on a test data and its performance investigation using a confusion matrix.


Getting Started

$ git clone https://github.com/nathanlem1/SVM_PyTorch.git
$ cd SVM_PyTorch
$ python SVM_PyTorch.py

To train,

$ python SVM_PyTorch_train.py

To test,

$ python SVM_PyTorch_test.py

Dependencies

About

This implements a linear SVM using fully-connected layer and hinge loss using PyTorch.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages