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
@kastnerkyle
kastnerkyle / kmeans.py
Created March 15, 2016 14:43 — forked from mblondel/kmeans.py
Fuzzy K-means and K-medians
# Copyright Mathieu Blondel December 2011
# License: BSD 3 clause
import numpy as np
import pylab as pl
from sklearn.base import BaseEstimator
from sklearn.utils import check_random_state
from sklearn.cluster import MiniBatchKMeans
from sklearn.cluster import KMeans as KMeansGood
# 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'}
@kastnerkyle
kastnerkyle / lm_example.ipynb
Last active September 4, 2019 18:56 — forked from yoavg/lm_example
Unreasonable Effectiveness of LMs
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@kastnerkyle
kastnerkyle / install_ffmpeg_ubuntu.sh
Last active April 23, 2018 14:04 — forked from xdamman/install_ffmpeg_ubuntu.sh
Install latest ffmpeg on ubuntu 12.04 or 14.04 - added libfreetype for combination with fancy_youtube_encode.sh
#!/bin/bash
# Bash script to install latest version of ffmpeg and its dependencies on Ubuntu 12.04 or 14.04
# Inspired from https://gist.github.com/faleev/3435377
# Remove any existing packages:
sudo apt-get -y remove ffmpeg x264 libav-tools libvpx-dev libx264-dev
# Get the dependencies (Ubuntu Server or headless users):
sudo apt-get update