Skip to content

Instantly share code, notes, and snippets.

@shurain
shurain / mutual_info.py
Last active August 29, 2015 14:06 — forked from GaelVaroquaux/mutual_info.py
Non-parametric computation of entropy and mutual-information
'''
Non-parametric computation of entropy and mutual-information
Adapted by G Varoquaux for code created by R Brette, itself
from several papers (see in the code).
These computations rely on nearest-neighbor statistics
'''
import numpy as np
@shurain
shurain / dnn.py
Last active August 29, 2015 14:12 — forked from syhw/dnn.py
A deep neural network with or w/o dropout in one file.
"""
A deep neural network with or w/o dropout in one file.
License: Do What The Fuck You Want to Public License http://www.wtfpl.net/
"""
import numpy, theano, sys, math
from theano import tensor as T
from theano import shared
from theano.tensor.shared_randomstreams import RandomStreams
@shurain
shurain / conv_deconv_vae.py
Last active August 29, 2015 14:15 — forked from kastnerkyle/conv_deconv_vae.py
conv_deconv_vae.py
# Alec Radford, Indico, Kyle Kastner
# License: MIT
"""
Convolutional VAE in a single file.
Bringing in code from IndicoDataSolutions and Alec Radford (NewMu)
Additionally converted to use default conv2d interface instead of explicit cuDNN
"""
import theano
import theano.tensor as T
from theano.sandbox.rng_mrg import MRG_RandomStreams as RandomStreams
on replace_chars(this_text, search_string, replacement_string)
set AppleScript's text item delimiters to the search_string
set the item_list to every text item of this_text
set AppleScript's text item delimiters to the replacement_string
set this_text to the item_list as string
set AppleScript's text item delimiters to ""
return this_text
end replace_chars
tell application "Google Chrome"
# Authors: Kyle Kastner
# License: BSD 3-clause
import theano.tensor as T
import numpy as np
import theano
class rmsprop(object):
"""
RMSProp with nesterov momentum and gradient rescaling
@shurain
shurain / gist:d26d44d7ef0ea1908b10
Last active August 29, 2015 14:25 — forked from karpathy/gist:587454dc0146a6ae21fc
An efficient, batched LSTM.
"""
This is a batched LSTM forward and backward pass
"""
import numpy as np
import code
class LSTM:
@staticmethod
def init(input_size, hidden_size, fancy_forget_bias_init = 3):
@shurain
shurain / antoniak.py
Last active September 15, 2015 16:37 — forked from tdhopper/antoniak.py
Sample from Antoniak Distribution with Python. `rand_antoniak` draws a sample from the distribution of tables created by a Chinese restaurant process with parameter `alpha` after `n` patrons are seated. Some notes on this distribution are here: http://www.cs.cmu.edu/~tss/antoniak.pdf.
import numpy as np
from numpy.random import choice
def stirling(N, m):
if N < 0 or m < 0:
raise Exception("Bad input to stirling.")
if m == 0 and N > 0:
return 0
elif (N, m) == (0, 0):
return 1
""" Poisson-loss Factorization Machines with Numba"""
# Author: Vlad Niculae <[email protected]>
# License: Simplified BSD
from __future__ import print_function
import numpy as np
from numba import jit
from scipy import sparse as sp
from sklearn.utils import check_random_state, check_array, check_X_y
@shurain
shurain / nginx.conf
Created January 11, 2016 03:48 — forked from plentz/nginx.conf
Best nginx configuration for improved security(and performance). Complete blog post here http://tautt.com/best-nginx-configuration-for-security/
# to generate your dhparam.pem file, run in the terminal
openssl dhparam -out /etc/nginx/ssl/dhparam.pem 2048
@shurain
shurain / arxiv2kindle.ipynb
Created January 16, 2016 15:19 — forked from bshillingford/arxiv2kindle.ipynb
arxiv2kindle: recompiles an arxiv paper for kindle-sized screens, and sends it to your wifi-enabled kindle
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.