Skip to content

Instantly share code, notes, and snippets.

@mrgloom
mrgloom / MNIST PCA projection
Last active May 7, 2020 12:18
MNIST PCA projection using scikit-learn.
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
#use all digits
mnist = fetch_mldata("MNIST original")
X_train, y_train = mnist.data[:70000] / 255., mnist.target[:70000]
@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"
@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
name: "VGG_ILSVRC_16_layer"
layer {
name: "data"
type: "DenseImageData"
top: "data"
top: "label"
dense_image_data_param {
source: "/home/myuser/Downloads/SegNet/SegNet-Tutorial/CamVid/train.txt" # Change this to the absolute path to your data file
batch_size: 1 # Change this number to a batch size that will fit on your GPU
shuffle: true
@mrgloom
mrgloom / Convolutional Arithmetic.ipynb
Created May 12, 2017 16:44 — forked from akiross/Convolutional Arithmetic.ipynb
Few experiments on how convolution and transposed convolution (deconvolution) should work in tensorflow.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@mrgloom
mrgloom / Find header and libs cheatsheet
Last active May 2, 2017 15:41
Find OpenCV function in headers and libs
#To find function in headers
grep -n -r <function_name> <path_to_opencv_include_folder>
#To find function in libs
nm -C -A <path_to_opencv_lib_folder>/*.so | grep <function_name> | grep -v U
#Find package installed via apt-get
apt list --installed | grep <package_name>
#Find files related to package
dpkg -L <package_name>
@mrgloom
mrgloom / online_stats.py
Created March 15, 2017 15:12 — forked from kastnerkyle/online_stats.py
Online statistics in numpy
# 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/
"""
name: "VGG_ILSVRC_16_layers"
layer {
name: "train-data"
type: "Data"
top: "data"
top: "label"
include {
stage: "train"
}
@mrgloom
mrgloom / detect_multiscale.cpp
Created May 23, 2016 13:20 — forked from thorikawa/detect_multiscale.cpp
Simple example for CascadeClassifier.detectMultiScale
#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")) {
@mrgloom
mrgloom / segnet_simple_train.prototxt
Created March 31, 2016 14:18
segnet_simple_train.prototxt
name: "segnet"
layer {
name: "data"
type: "DenseImageData"
top: "data"
top: "label"
dense_image_data_param {
source: "/SegNet/CamVid/train.txt" # Change this to the absolute path to your data file
batch_size: 4 # Change this number to a batch size that will fit on your GPU