Skip to content

Instantly share code, notes, and snippets.

View ebenolson's full-sized avatar

Eben Olson ebenolson

  • Presco Engineering
  • Woodbridge, CT
View GitHub Profile
@ebenolson
ebenolson / dnn.py
Created August 12, 2014 13:23 — forked from syhw/dnn.py
"""
A deep neural network with or w/o dropout in one file.
"""
import numpy, theano, sys, math
from theano import tensor as T
from theano import shared
from theano.tensor.shared_randomstreams import RandomStreams
from collections import OrderedDict
@ebenolson
ebenolson / draw_net.py
Created March 27, 2015 23:01
Functions to draw Lasagne networks with graphviz, like Caffe's draw_net.py
"""
Functions to create network diagrams from a list of Layers.
Examples:
Draw a minimal diagram to a pdf file:
layers = lasagne.layers.get_all_layers(output_layer)
draw_to_file(layers, 'network.pdf', output_shape=False)
Draw a verbose diagram in an IPython notebook:
@ebenolson
ebenolson / MNIST contrastive.ipynb
Created March 29, 2015 14:39
MNIST contrastive
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
# 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.compat.python2x import OrderedDict
from lasagne.layers import Layer
class HighwayLayer(Layer):
def __init__(self, incoming, layer_class, gate_nonlinearity=None,
**kwargs):
super(HighwayLayer, self).__init__(incoming)
self.H_layer = layer_class(incoming, **kwargs)
if gate_nonlinearity:
# Usage: experiment.sh SOURCE_FILE LOG_COMMIT_MESSAGE
if [ $# -eq 0 ]
then
echo "Usage: experiment.sh SOURCE_FILE [LOG_COMMIT_MESSAGE]"
exit -1
fi
if [ $# -eq 2 ]
then
require 'optim'
cj = require('cjson')
a = torch.Tensor({0.1,0.2,0.3})
x0 = torch.Tensor({1, 1, 1})
function f(x)
return torch.sum(torch.cmul(a, torch.pow(x, 2)))
end
@ebenolson
ebenolson / model.prototxt
Last active August 29, 2015 14:24 — forked from mavenlin/readme.md
Network in Network CIFAR10
name: "CIFAR10_full"
input: "data"
input_shape {
dim: 1
dim: 3
dim: 32
dim: 32
}
layers {
name: "conv1"
import numpy as np
import gc
import memory_profiler
import theano
import theano.tensor as T
from theano.sandbox.cuda.dnn import dnn_conv
X = T.tensor4()
W = T.tensor4()
@ebenolson
ebenolson / bvlc_googlenet.py
Created July 16, 2015 15:31
BVLC GoogleNet translated to Lasagne
from lasagne.layers import InputLayer
from lasagne.layers import DenseLayer
from lasagne.layers import ConcatLayer
from lasagne.layers import NonlinearityLayer
from lasagne.layers import GlobalPoolLayer
from lasagne.layers.dnn import Conv2DDNNLayer as ConvLayer
from lasagne.layers.dnn import MaxPool2DDNNLayer as PoolLayerDNN
from lasagne.layers import MaxPool2DLayer as PoolLayer
from lasagne.layers import LocalResponseNormalization2DLayer as LRNLayer
from lasagne.nonlinearities import softmax, linear