Skip to content

Instantly share code, notes, and snippets.

@mrgloom
mrgloom / dnn_compare_optims.py
Last active February 9, 2018 18:04 — forked from syhw/dnn_compare_optims.py
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

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
@mrgloom
mrgloom / gist:2101cef88005987e9870
Created July 10, 2015 12:08
cvSnakeImage() example
+/*
+ * Author: Samyak Datta (datta[dot]samyak[at]gmail.com)
+ *
+ * A program to demonstrate contour detection using the Active Contour
+ * Model (Snake). The cvSnakeImage() method is applied to detect lip
+ * contour in a lip ROI image.
+ *
+ */
+
+#include "opencv2/highgui/highgui.hpp"

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:
@mrgloom
mrgloom / gist:691df379c79b37710595
Created May 6, 2015 21:05
hog + linear svm testing
#include "CsvWriter.h"
#include <windows.h>
#include <time.h> // for random number generator
#include <string>
#include <vector>
#include <fstream> // std::ofstream
@mrgloom
mrgloom / gist:4713c5ceddfd2d15d225
Created November 27, 2014 12:15
CPU vs GPU test using Matlab
%gpuDevice() %info about GPU
clear
gpuDevice(1); %reset GPU device
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%test matrix multiplication
try
%n= 100;
for m=100:100:10000
n=m;
@mrgloom
mrgloom / gist:3943410759f04265f7cb
Created November 13, 2014 09:43
Matlab SVD projection
>> a = [1 2 3; 2 5 7; 3 7 9]
a =
1 2 3
2 5 7
3 7 9
>> [U S V] = svd(a)
@mrgloom
mrgloom / CUR4FIC
Created July 24, 2014 13:30 — forked from goldingn/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
@mrgloom
mrgloom / svm.py
Created June 4, 2014 09:41 — forked from mblondel/svm.py
# Mathieu Blondel, September 2010
# License: BSD 3 clause
import numpy as np
from numpy import linalg
import cvxopt
import cvxopt.solvers
def linear_kernel(x1, x2):
return np.dot(x1, x2)
import numpy as np
import time
def read_data():
#M x N
data= np.loadtxt("data_3d.txt",delimiter=" ", skiprows=1, usecols=(0,1,2))
print data.shape
# print data
return data