Skip to content

Instantly share code, notes, and snippets.

@amueller
amueller / gist:4299381
Created December 15, 2012 21:26
Plotting PCAs of pairs of MNIST digit classes
import numpy as np
import matplotlib.pyplot as plt
from itertools import product
from sklearn.decomposition import RandomizedPCA
from sklearn.datasets import fetch_mldata
from sklearn.utils import shuffle
mnist = fetch_mldata("MNIST original")
X_train, y_train = mnist.data[:60000] / 255., mnist.target[:60000]
@GaelVaroquaux
GaelVaroquaux / bench_dbscan.py
Last active December 20, 2015 10:19
Benchmarking scikit_learn 0.14.X release
import numpy as np
import time
from sklearn import cluster
from sklearn import datasets
lfw = datasets.fetch_lfw_people()
X_lfw = lfw.data[:, :5]
eps = 8. # This choice of EPS gives 44 clusters
@goldingn
goldingn / CUR4FIC
Last active January 3, 2016 05:49
Playing with CUR decomposition (versus k-means) as a method for picking inducing points in sparse Gaussian processes
# clear the workspace
rm(list = ls())
# load the relevant libraries
# install.packages(rCUR)
library(rCUR) # for CUR decomposition
# install.packages(irlba)
library(irlba) # for fast svd
@syhw
syhw / dnn_compare_optims.py
Created July 21, 2014 09:07
comparing SGD vs SAG vs Adadelta vs Adagrad
"""
A deep neural network with or w/o dropout in one file.
"""
import numpy
import theano
import sys
import math
from theano import tensor as T
from theano import shared
@amueller
amueller / learning_gabor_filters.py
Created April 19, 2012 11:39
Learning Gabor filters with scikit-learn and ICA or k-means
import numpy as np
import matplotlib.pyplot as plt
from sklearn.datasets import fetch_mldata
from sklearn.decomposition import FastICA, PCA
from sklearn.cluster import KMeans
# fetch natural image patches
image_patches = fetch_mldata("natural scenes data")
X = image_patches.data
@iandees
iandees / dlib_plus_osm.md
Last active May 30, 2018 19:07
Detecting Road Signs in Mapillary Images with dlib C++

image

I've been interested in computer vision for a long time, but I haven't had any free time to make any progress until this holiday season. Over Christmas and the New Years I experimented with various methodologies in OpenCV to detect road signs and other objects of interest to OpenStreetMap. After some failed experiments with thresholding and feature detection, the excellent /r/computervision suggested using the dlib C++ module because it has more consistently-good documentation and the pre-built tools are faster.

After a day or two figuring out how to compile the examples, I finally made some progress:

Compiling dlib C++ on a Mac with Homebrew

  1. Clone dlib from Github to your local machine:
@tariqmislam
tariqmislam / instructions and how-to
Created March 22, 2012 15:58
Setting Up Hadoop 0.20.2 on Windows 7 With Cygwin
=================================================================
SETTING UP SSHD AS A SERVICE FOR RUNNING HADOOP DAEMONS ON WINDOWS 7
=================================================================
Steps:
1. Download 'setup.exe' from Cygwin website
2. Right-click on 'setup.exe'
3. Leave settings as they are, click through until you come to the plugin selection window
3.1 - Make sure that the installation directory is 'C:\cygwin'
@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.
//
@kylemcdonald
kylemcdonald / pytorch_setup.sh
Created August 29, 2018 02:48
Install CUDA 9.2, cuDNN 7.2.1, Anaconda and PyTorch on Ubuntu 16.04.
# tested on AWS p2.xlarge August 29, 2018
# install CUDA
sudo apt-get update && sudo apt-get install wget -y --no-install-recommends
CUDA_URL="https://developer.nvidia.com/compute/cuda/9.2/Prod2/local_installers/cuda-repo-ubuntu1604-9-2-local_9.2.148-1_amd64"
wget -c ${CUDA_URL} -O cuda.deb
sudo dpkg --install cuda.deb
sudo apt-key add /var/cuda-repo-9-2-local/7fa2af80.pub
sudo apt-get update
sudo apt-get install -y cuda
class OnlineLearner(object):
def __init__(self, **kwargs):
self.last_misses = 0.
self.iratio = 0.
self.it = 1.
self.l = kwargs["l"]
self.max_ratio = -np.inf
self.threshold = 500.
def hinge_loss(self, vector, cls, weight):