kuddai / mnist_svm_example

c++ mnist svm example (opencv, vlfeat)

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

MNIST SVM EXAMPLE

c++ 14 of SVM classification example on MNIST dataset using vlfeat and opencv.

Linear SVM is utilized for performance reasons although with some optional preprocessing (PCA decomposition, quadratic interaction terms).

With lambda 0.0002, beta 1, epsilon 0.00005, and 86% of variational variance preserved by PCA, it can attain around 97.47% accuracy on test set. This result is in good match with results described here, as essentialy we are using PCA with quadratic classifier.

To reproduce results run the following commands:

# to generate dataset with train and test descriptions (text file containing on each line path to png image and its label). python 2.7 is required, with pypng
python convert_mnist_to_png.py mnist/ mnist_png
# build program (gcc, c++14, opencv are required)
mkdir build; cd build; cmake ..; make;
mv mnist_png build/code
cv build/code
# training
./main train mnist_png/training/description.txt saved_model preprocessed 0.0002 1 0.00005 0.86
# classifcation
./main classify saved_model mnist_png/testing/description.txt predictions.txt preprocessed
# validation
python ../../validate.py --truth mnist_png/testing/description.txt --predictions predictions.txt

About

c++ mnist svm example (opencv, vlfeat)

License:GNU General Public License v2.0


Languages

Language:C 52.8%Language:C++ 16.3%Language:MATLAB 15.7%Language:HTML 5.9%Language:Python 3.2%Language:Makefile 2.6%Language:CSS 1.2%Language:Objective-C 1.1%Language:Roff 0.4%Language:TeX 0.3%Language:Clean 0.3%Language:Shell 0.1%Language:M 0.1%Language:CMake 0.0%