Skip to content

Instantly share code, notes, and snippets.

@mrgloom
mrgloom / Convolutional Arithmetic.ipynb
Created May 12, 2017 — forked from akiross/Convolutional Arithmetic.ipynb
Few experiments on how convolution and transposed convolution (deconvolution) should work in tensorflow.
View Convolutional Arithmetic.ipynb
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@mrgloom
mrgloom / online_stats.py
Created Mar 15, 2017 — forked from kastnerkyle/online_stats.py
Online statistics in numpy
View online_stats.py
# Author: Kyle Kaster
# License: BSD 3-clause
import numpy as np
def online_stats(X):
"""
Converted from John D. Cook
http://www.johndcook.com/blog/standard_deviation/
"""
@mrgloom
mrgloom / detect_multiscale.cpp
Created May 23, 2016 — forked from thorikawa/detect_multiscale.cpp
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")) {
View pegasos.py
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):
@mrgloom
mrgloom / rbm.py
Last active Sep 11, 2015
Some fairly clean (and fast) code for Restricted Boltzmann machines.
View rbm.py
"""
Code for training RBMs with contrastive divergence. Tries to be as
quick and memory-efficient as possible while utilizing only pure Python
and NumPy.
"""
# Copyright (c) 2009, David Warde-Farley
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
@mrgloom
mrgloom / kmtransformer.py
Last active Aug 31, 2015 — forked from larsmans/kmtransformer.py
k-means feature mapper for scikit-learn
View kmtransformer.py
from sklearn.base import BaseEstimator, TransformerMixin
from sklearn.metrics.pairwise import rbf_kernel
class KMeansTransformer(BaseEstimator, TransformerMixin):
def __init__(self, centroids):
self.centroids = centroids
def fit(self, X, y=None):
return self
@mrgloom
mrgloom / dnn_compare_optims.py
Last active Feb 9, 2018 — forked from syhw/dnn_compare_optims.py
comparing SGD vs SAG vs Adadelta vs Adagrad
View dnn_compare_optims.py
"""
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
View roll_ipython_in_aws.md

What

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
View dlib_plus_osm.md

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:
View CUR4FIC
# 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