Skip to content

Instantly share code, notes, and snippets.

@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.
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 March 15, 2017 15:12 — 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/
"""
View VGG-16
name: "VGG_ILSVRC_16_layers"
layer {
name: "train-data"
type: "Data"
top: "data"
top: "label"
include {
stage: "train"
}
@mrgloom
mrgloom / Find header and libs cheatsheet
Last active May 2, 2017 15:41
Find OpenCV function in headers and libs
View Find header and libs cheatsheet
#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 / detect_multiscale.cpp
Created May 23, 2016 13:20 — 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")) {
@mrgloom
mrgloom / segnet_simple_train.prototxt
Created March 31, 2016 14:18
segnet_simple_train.prototxt
View 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
View segnet_train_downsampled.prototxt
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 / pegasos.py
Created October 13, 2015 16:58 — forked from alextp/pegasos.py
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 September 11, 2015 09:59
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 August 31, 2015 13:46 — 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