Skip to content

Instantly share code, notes, and snippets.

View kastnerkyle's full-sized avatar

Kyle Kastner kastnerkyle

View GitHub Profile
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@kastnerkyle
kastnerkyle / Optimizer.py
Last active September 17, 2015 10:08 — forked from jiahao/Optimizer.py
Pure Python implementation of some numerical optimizers
#!/usr/bin/env python
'''
Pure Python implementation of some numerical optimizers
Created on Jan 21, 2011
@author Jiahao Chen
'''
class SPPLayer(lasagne.layers.Layer):
def __init__(self, incoming, **kwargs):
super(SPPLayer, self).__init__(incoming, **kwargs)
# divide by 4 gives 16 patches
self.win1 = (int(np.floor(incoming.output_shape[2]/4.0)), int(np.floor(incoming.output_shape[3]/4.0)))
self.str1 = (int(np.ceil(incoming.output_shape[2]/4.0)), int(np.ceil(incoming.output_shape[3]/4.0)))
# divide by 2 gives 4 patches
self.win2 = (int(np.floor(incoming.output_shape[2]/2.0)), int(np.floor(incoming.output_shape[3]/2.0)))
@kastnerkyle
kastnerkyle / gist:8d82b4f93705e339354f
Created December 12, 2015 17:11 — forked from anonymous/gist:0a6e9ceccd30e1d5f992
Mixture of Gaussian densities, and derivatives
def gaussian_density_batch(x, mean, stddev, correlation, compute_derivatives=False):
"""
Compute the Gaussian density at x for a 2D normal distribution with parameters mean, stddev, correlation.
This works simultaneously on a batch of inputs. The inputs should have dimensions:
x.shape = (n, 1, 2)
mean.shape = stddev.shape = (n, m, 2)
correlation.shape = (n, m, 1)
where n*m is the number of different Gaussian density functions that we want to evaluate, on n input points x.
So the same input x is plugged into the density for m Gaussian pdfs. (This is convenient for evaluating a
# smidi.py: A simple midi-file library
# make a single file version for midi-outfile only.
# Original code is from Max M's site here (GPL)
# http://www.mxm.dk/products/public/pythonmidi
# Modified by korakot,
# http://snippets.dzone.com/posts/show/572
"""
include source codes from
- constants.py
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
import os
import requests
from bs4 import BeautifulSoup
class GSheet(object):
base_sheet_url = 'https://spreadsheets.google.com/feeds/worksheets/{0}/private/full'
list_worksheet_url = 'https://spreadsheets.google.com/feeds/list/{0}/{{}}/private/full'
cell_worksheet_url = 'https://spreadsheets.google.com/feeds/cells/{0}/{{}}/private/full'
HTTPheaders = {'content-type': 'application/atom+xml'}
import types
import tensorflow as tf
import numpy as np
# Expressions are represented as lists of lists,
# in lisp style -- the symbol name is the head (first element)
# of the list, and the arguments follow.
# add an expression to an expression list, recursively if necessary.
def add_expr_to_list(exprlist, expr):
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@kastnerkyle
kastnerkyle / maxout_theano.py
Created August 3, 2016 16:05
Maxout Theano
"""
Maxout implementation in Theano
"""
# W,b - Parameters in neural network layer
# activation - Activation function
# maxoutsize - Number of input neurons to maxout units
# Output activation function
output = activation(T.dot(input,W) + b)