Skip to content

Instantly share code, notes, and snippets.

kylemcdonald /
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
wget -c ${CUDA_URL} -O cuda.deb
sudo dpkg --install cuda.deb
sudo apt-key add /var/cuda-repo-9-2-local/
sudo apt-get update
sudo apt-get install -y cuda
iandees /
Last active May 30, 2018 19:07
Detecting Road Signs in Mapillary Images with dlib C++


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:
syhw /
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
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
GaelVaroquaux /
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 =[:, :5]
eps = 8. # This choice of EPS gives 44 clusters
spaghetti-source /
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
// and extract them.
iamatypeofwalrus /
Last active February 22, 2022 22:25
Create an iPython HTML Notebook on Amazon's AWS Free Tier from scratch.


Roll your own iPython Notebook server with Amazon Web Services (EC2) using their Free Tier.

What are we using? What do you need?

  • An active AWS account. First time sign-ups are eligible for the free tier for a year
  • One Micro Tier EC2 Instance
  • With AWS we will use the stock Ubuntu Server AMI and customize it.
  • Anaconda for Python.
  • Coffee/Beer/Time
larsmans /
Created February 14, 2013 13:38
k-means clustering in pure Python
# K-means clustering using Lloyd's algorithm in pure Python.
# Written by Lars Buitinck. This code is in the public domain.
# The main program runs the clustering algorithm on a bunch of text documents
# specified as command-line arguments. These documents are first converted to
# sparse vectors, represented as lists of (index, value) pairs.
from collections import defaultdict
thorikawa / detect_multiscale.cpp
Created January 15, 2013 09:36
Simple example for CascadeClassifier.detectMultiScale
View detect_multiscale.cpp
#include <opencv2/opencv.hpp>
#include <vector>
using namespace cv;
using namespace std;
int main () {
Mat img = imread("lena.jpg");
CascadeClassifier cascade;
if (cascade.load("haarcascade_frontalface_alt.xml")) {
amueller / gist:4299381
Created December 15, 2012 21:26
Plotting PCAs of pairs of MNIST digit classes
View gist:4299381
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 =[:60000] / 255.,[:60000]