Skip to content

Instantly share code, notes, and snippets.

View kastnerkyle's full-sized avatar

Kyle Kastner kastnerkyle

View GitHub Profile
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):
@kastnerkyle
kastnerkyle / beamsearch.py
Created July 8, 2016 07:34 — forked from udibr/beamsearch.py
beam search for Keras RNN
# variation to https://github.com/ryankiros/skip-thoughts/blob/master/decoding/search.py
def keras_rnn_predict(samples, empty=empty, rnn_model=model, maxlen=maxlen):
"""for every sample, calculate probability for every possible label
you need to supply your RNN model and maxlen - the length of sequences it can handle
"""
data = sequence.pad_sequences(samples, maxlen=maxlen, value=empty)
return rnn_model.predict(data, verbose=0)
def beamsearch(predict=keras_rnn_predict,
Loading
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)
@kastnerkyle
kastnerkyle / install-tensorflow.sh
Created September 10, 2016 17:56 — forked from erikbern/install-tensorflow.sh
Installing TensorFlow on EC2
# Note – this is not a bash script (some of the steps require reboot)
# I named it .sh just so Github does correct syntax highlighting.
#
# This is also available as an AMI in us-east-1 (virginia): ami-cf5028a5
#
# The CUDA part is mostly based on this excellent blog post:
# http://tleyden.github.io/blog/2014/10/25/cuda-6-dot-5-on-aws-gpu-instance-running-ubuntu-14-dot-04/
# Install various packages
sudo apt-get update
#!/usr/bin/env python
# gpu_stat.py [DELAY [COUNT]]
# dump gpu stats as a line of json
# {"time": 1474168378.146957, "pci_tx": 146000, "pci_rx": 1508000,
# "gpu_util": 42, "mem_util": 24, "mem_used": 11710,
# "temp": 76, "fan_speed": 44 }
# author: Aaditya Prakash
# NVIDIA-SMI does not show the full command, and when it was launched and its RAM usage.
# PS does but it does but you need PIDs for that
# lsof /dev/nvidia gives PIDs but only for the user invoking it
# usage:
# python programs_on_gpu.py
# Sample Output
@kastnerkyle
kastnerkyle / pavoque.py
Created January 13, 2017 00:38 — forked from sotelo/pavoque.py
pavoque to hdf5
from run_merlin import prepare_file_path_list, read_file_list
from io_funcs.binary_io import BinaryIOCollection
import numpy
import h5py
import pickle
from fuel.datasets.hdf5 import H5PYDataset
io_fun = BinaryIOCollection()
n_outs = 63 # 187
#!/usr/bin/env python
# Based on code from Laurent Dinh (laurent-dinh)
# Author: Kyle Kastner
# License: BSD 3-Clause
import requests
import time
import random
from bs4 import BeautifulSoup
import urllib