Skip to content

Instantly share code, notes, and snippets.

View spaghetti-source's full-sized avatar

Takanori MAEHARA spaghetti-source

View GitHub Profile
@spaghetti-source
spaghetti-source / kNNmnist.cc
Last active December 17, 2015 14:19
k-NN classification for MNIST dataset
//
// Nearlest Neighbour Classification for MNIST dataset
//
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <map>
#include <vector>
#include <queue>
@spaghetti-source
spaghetti-source / readmnist.cc
Created May 21, 2013 14:35
Read MNIST Database (handwritten digits)
// Read MNIST Database (handwritten digits)
//
// Usage:
// 1. download
// train-images-idx3-ubyte.gz
// train-labels-idx2-ubyte.gz
// from
// http://yann.lecun.com/exdb/mnist/
// and extract them.
//
% Radial Basis Function expansion
%
% f(x) = sum k(x, yi) wi
% -> w = k(X,Y) \ f(X)
% here k(x,y) := rho(|x-y|), e.g., exp(-|x-y2|^2)
% input data
N = 100;
X = rand(N,1);
fX = abs( cos( 2 * 3.14 * (X .* X) ) );
@spaghetti-source
spaghetti-source / 2layerNN.cc
Last active December 17, 2015 11:59
Two-layer Neural Network
// Two-layer Neural Network
//
// USAGE:
// ./a.out in.txt out.txt
// gnuplot -e "plot 'in.txt', 'out.txt'; pause 2"
//
#include <iostream>
#include <cstdio>
#include <ctime>
#include <cstdlib>
@spaghetti-source
spaghetti-source / LUdecomposition.cc
Created April 29, 2013 15:38
Simple Sparse Linear Solver
//
// Sparse LU Decomposition (Gilbert-Peierls)
//
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <vector>
#include <functional>
#include <algorithm>
#include <cmath>