Skip to content

Instantly share code, notes, and snippets.

View Sentient07's full-sized avatar

Ramana Sundararaman Sentient07

View GitHub Profile
@Sentient07
Sentient07 / attempt_gs.py
Last active June 14, 2017 12:01
Gumbel softmax draft in theano
import numpy as np
import theano
import theano.tensor as tensor
rng = np.random.RandomState(1)
srng = RandomStreams(rng.randint(1234))
def get_one_hot(inp, nb_samples, nb_class):
m = tensor.zeros((nb_samples, nb_class))
m = tensor.set_subtensor(m[tensor.arange(nb_samples), tensor.argmax(inp, -1)], 1)
@Sentient07
Sentient07 / theano-fastrcnn.py
Last active December 23, 2017 03:06
Implementation of Fast-RCNN in theano (using Lasagne)
# Faster RCNN VGG Net
"""
The VGG network is adapted from: https://github.com/Lasagne/Recipes/blob/master/modelzoo/vgg16.py
"""
import theano
import theano.tensor as tensor
from lasagne.layers import InputLayer, DenseLayer, NonlinearityLayer, DropoutLayer
from lasagne.layers import Pool2DLayer as PoolLayer, RoIPoolLayer
from lasagne.layers import Conv2DLayer as ConvLayer, get_output, get_all_params
from lasagne.init import Normal
@Sentient07
Sentient07 / sppooling.py
Last active January 11, 2017 21:39
Failing test for variable stride
import theano
from theano import tensor as T
from theano.tensor.signal.pool import pool_2d
import numpy as np
def spp_pooling(data, out_dimension, data_shape):
input_size = data_shape[2:]
pooled_data_list = []
for pool_dim in out_dimension:
import numpy as np
import theano
import theano.tensor as T
import resource
def random_matrix_mult():
mat1 = T.fmatrix('mat1')
mat2 = T.fmatrix('mat2')
col_index = np.arange(0, 150000, 5000)
row_index = np.arange(10000)
alabaster==0.7.7
appdirs==1.4.0
appnope==0.1.0
Babel==2.2.0
backports-abc==0.4
backports.ssl-match-hostname==3.5.0.1
certifi==2015.11.20.1
cv2==1.0
cycler==0.10.0
Cython==0.23.4
name: "CIFAR10_full_deploy"
# N.B. input image must be in CIFAR-10 format
# as described at http://www.cs.toronto.edu/~kriz/cifar.html
layer {
name: "data"
type: "Input"
top: "data"
input_param { shape: { dim: 1 dim: 3 dim: 32 dim: 32 } }
}
layer {
name: "CaffeNet"
layer {
name: "data"
type: "Input"
top: "data"
input_param { shape: { dim: 10 dim: 3 dim: 227 dim: 227 } }
}
layer {
name: "conv1"
type: "Convolution"
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@Sentient07
Sentient07 / large-graphs.py
Created March 13, 2016 23:34
A failing example of large graph in theano due to max recursion depth error
#!/usr/bin/python
import theano.tensor as T
import theano
from cgt.utils import Message
import time
import cgt
if __name__ == '__main__':
a = T.scalar(name='a', dtype='int64') #
b = T.scalar(name='b', dtype='int64')
@Sentient07
Sentient07 / serialisation.py
Created March 11, 2016 14:17
An example where serialization throws maximum recursion depth exceeded RuntimeError
class Node():
pass
nodes = []
for i in range( 100 ):
n = Node()
nodes.append( n )