Skip to content

Instantly share code, notes, and snippets.

@rjpower
rjpower / stop-distance.ipynb
Last active August 27, 2015 04:16
optimal stop distance for bus service
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
from data import ROOT
class SchemaBuilder(object):
def __init__(self, prefix=''):
self.last_key = ''
self.prefix = prefix
self.results = {}
def parse(self, obj, my_key='Root'):
if obj is None: return 'Any'
import numpy as np
from keras.models import Sequential
from keras.layers.core import Dense, Activation, Dropout, TimeDistributedDense
from keras.layers.recurrent import LSTM
text = open('/home/russellp/w/data/citation-graph/abstracts.txt', 'r').read()
char_to_idx = { ch: i for (i, ch) in enumerate(sorted(list(set(text)))) }
idx_to_char = { i: ch for (ch, i) in char_to_idx.items() }
vocab_size = len(char_to_idx)
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@rjpower
rjpower / keras_bow_grid_search.ipynb
Created April 4, 2016 19:05
Grid search over a number of topologies.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@rjpower
rjpower / setup-cuda.sh
Last active January 4, 2023 08:14
Install CUDA kernel module and system libraries for Ubuntu
echo 'deb http://developer.download.nvidia.com/compute/cuda/repos/ubuntu1404/x86_64 /' > /etc/apt/sources.list.d/cuda.list
echo 'deb http://developer.download.nvidia.com/compute/machine-learning/repos/ubuntu1404/x86_64 /' > /etc/apt/sources.list.d/nvidia-ml.list
apt-get update
apt-get install --force-yes -y nvidia-352
apt-get install --force-yes -y cuda-7-5 cuda-command-line-tools-7-5 cuda-core-7-5 cuda-cublas-7-5 cuda-cublas-dev-7-5 cuda-cudart-7-5 cuda-cudart-dev-7-5 cuda-cufft-7-5 cuda-cufft-dev-7-5 cuda-curand-7-5 cuda-curand-dev-7-5 cuda-cusolver-7-5 cuda-cusolver-dev-7-5 cuda-cusparse-7-5 cuda-cusparse-dev-7-5 cuda-documentation-7-5 cuda-driver-dev-7-5 cuda-gdb-src-7-5 cuda-ld-conf-7-5 cuda-license-7-5 cuda-minimal-build-7-5 cuda-misc-headers-7-5 cuda-npp-7-5 cuda-npp-dev-7-5 cuda-nvrtc-7-5 cuda-nvrtc-dev-7-5 cuda-runtime-7-5 cuda-samples-7-5 cuda-toolkit-7-5 cuda-visual-tools-7-5
apt-get install -y build-essential python-dev python-virtualenv python-pip
apt-get install -y libatlas-dev liblapack-dev
ap
@rjpower
rjpower / bow-embedding-keras.py
Created June 2, 2016 22:08
BOW embedding layers for Keras
class BOW(Embedding):
'''
Bag-of-words embedding layer.
The default embedding layer outputs the concatenation of [W_t * one_hot(input)];
this layer simply sums over the resulting output.
'''
def get_output_shape_for(self, input_shape):
return (input_shape[0], self.output_dim)
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@rjpower
rjpower / custom.html
Last active June 16, 2016 21:25
jupyter styling
<!-- originally from: https://raw.githubusercontent.com/barbagroup/CFDPython/master/styles/custom.css -->
<link href='http://fonts.googleapis.com/css?family=Fenix' rel='stylesheet' type='text/css'>
<link href='http://fonts.googleapis.com/css?family=Alegreya+Sans:100,300,400,500,700,800,900,100italic,300italic,400italic,500italic,700italic,800italic,900italic' rel='stylesheet' type='text/css'>
<link href='http://fonts.googleapis.com/css?family=Source+Code+Pro:300,400' rel='stylesheet' type='text/css'>
<style>
@font-face {
font-family: "Computer Modern";
src: url('http://mirrors.ctan.org/fonts/cm-unicode/fonts/otf/cmunss.otf');
}