This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
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 |
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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/ | |
""" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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")) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from sklearn.grid_search import GridSearchCV | |
from sklearn.cross_validation import StratifiedKFold | |
def main(): | |
mnist = fetch_mldata("MNIST original") | |
X_all, y_all = mnist.data/255., mnist.target | |
print("scaling") | |
X = X_all[:60000, :] | |
y = y_all[:60000] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 = mnist.data[:60000] / 255., mnist.target[:60000] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import numpy as np | |
from matplotlib import pyplot as plt | |
from scipy.optimize import fmin_l_bfgs_b as bfgs | |
from scipy.io import loadmat | |
class params: | |
''' | |
A wrapper around weights and biases | |
for an autoencoder |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from numpy import loadtxt, zeros, ones, array, linspace, logspace | |
from pylab import scatter, show, title, xlabel, ylabel, plot, contour | |
#Evaluate the linear regression | |
def compute_cost(X, y, theta): | |
''' | |
Comput cost for linear regression | |
''' | |
#Number of training samples |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
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 |
NewerOlder