Skip to content

Instantly share code, notes, and snippets.

View dwf's full-sized avatar

David Warde-Farley dwf

View GitHub Profile
@dwf
dwf / gist:10165796
Created April 8, 2014 18:15
Dropout yaml file.
# These hyperparameters, identified by David Warde-Farley via random search,
# obtain 1.08% on MNIST, nearly matching the 1.05% in Nitish Srivastava's
# Master's thesis.
#
# An important difference is that this uses only the first 50,000 examples
# and does early stopping on a validation set of the last 10,000 training
# points, whereas Nitish Srivastava's results trained on the entire training
# set for a given number of epochs. It is quite possible that re-training
# with these hyperparameters on the entire 60,000 using some alternate stopping
# criterion (matching the best training set likelihood of this job, for instance,
@dwf
dwf / docscrape.py
Created February 25, 2014 19:53
Code extracted from the numpydoc package.
"""Extract reference documentation from the NumPy source tree.
"""
import inspect
import textwrap
import re
import sys
import types
@dwf
dwf / brightness_restore.sh
Last active January 3, 2016 15:59
Remedy my laptop's the annoying behaviour of setting an arbitrary brightness upon wake from sleep.
#!/bin/sh
# Script to restore the last value for brightness upon ACPI wake.
#
# Hilariously, while you can write a new brightness to
# /sys/class/backlight/intel_backlight/brightness,
#
# to accurately determine the current brightness you must use
# /sys/class/backlight/intel_backlight/actual_brightness,
@dwf
dwf / gist:8484148
Created January 18, 2014 00:16
A skeleton cumulative sum op for Theano.
import theano
import numpy
class CumSumOp(theano.Op):
"""Use as CumSumOp(axis)(input_arg)"""
def __init__(self, axis=None):
self.axis = axis
def __eq__(self, other):
return type(self) == type(other) and self.axis == other.axis
@dwf
dwf / unhexdump.py
Created November 13, 2013 22:07
Undo a textual hex dump (from the Firefox cache).
"""
Reverses a hex dump (of the format shown in the Firefox cache).
The format is as follows:
<OFFSET> <BYTE> [<BYTE> [<BYTE> [...]]] [render]
Where
- <OFFSET> is 8 hex digits, possibly followed by a colon
- each <BYTE> is (maximum 16 per line)
import numpy as np
import matplotlib.pyplot as plt
def plot_filters(filters, shape, num_rows, num_cols):
"""
Assumes filters are rows (so transpose it that way if necessary).
matplotlib isn't the speediest horse in town, I wouldn't draw
more than a few dozen this way if you need it to frequently update.
@dwf
dwf / reader.pyx
Last active February 10, 2017 08:45
A proof-of-concept for a multi-threaded pre-fetching loader for .NPY files.
"""
A proof-of-concept multi-threaded chunked NPY format reader.
"""
__author__ = "David Warde-Farley"
__credits__ = ["David Warde-Farley"]
__license__ = "3-clause BSD"
__email__ = 'd dot warde dot farley at gmail DOT com"
import threading
from numpy.lib.format import read_magic, read_array_header_1_0
#!/bin/sh
# Run pyflakes on all changed .py files before commit.
#
# By David Warde-Farley, Feb 28, 2013 -- released under the 3-clause BSD license.
#
# To use, run this file from the script .git/hooks/pre-commit
FILES=`git diff --staged --name-status |grep '\.py$' |grep '^[AM]' |sed -e's/^[AM]\s\+//'`
ROOT=`git rev-parse --show-toplevel`
NUM_BAD_FILES=0
@dwf
dwf / theanoprinting.py
Created December 19, 2012 21:21
IPython extension for automatically PNG-pretty-printing Theano functions with Graphviz.
"""Display Theano functions in the IPython notebook with pydotprint."""
__author__ = "David Warde-Farley"
__copyright__ = "Copyright 2012, Universite de Montreal"
__credits__ = ["David Warde-Farley"]
__license__ = "3-clause BSD"
__email__ = "wardefar@iro"
__maintainer__ = "David Warde-Farley"
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.