Skip to content

Instantly share code, notes, and snippets.

@ebenolson
Last active September 16, 2015 12:49
Show Gist options
  • Save ebenolson/4b2fe40ff677db7ca496 to your computer and use it in GitHub Desktop.
Save ebenolson/4b2fe40ff677db7ca496 to your computer and use it in GitHub Desktop.
import numpy as np
import theano
import theano.tensor as T
X = T.tensor3()
W = theano.shared(np.ones((1,1,1,3)).astype('float32'))
W_shape = (1, 1, 1, 3)
input = X
input_shape = (1, 1, 1, 10)
conved = T.nnet.conv2d(input.dimshuffle(0, 1, 'x', 2),
W,
image_shape=input_shape,
filter_shape=W_shape,
border_mode='valid',
).dimshuffle(0, 1, 3)
input = conved
input_shape = (1, 1, 1, 8)
shift = 1
conved = T.nnet.conv2d(input.dimshuffle(0, 1, 'x', 2),
W,
image_shape=input_shape,
filter_shape=W_shape,
border_mode='full',
).dimshuffle(0, 1, 3)
input = conved[:, :, shift:input.shape[2] + shift]
conved = T.nnet.conv2d(input.dimshuffle(0, 1, 'x', 2),
W,
image_shape=input_shape,
filter_shape=W_shape,
border_mode='full',
).dimshuffle(0, 1, 3)
input = conved[:, :, shift:input.shape[2] + shift]
conved = T.nnet.conv2d(input.dimshuffle(0, 1, 'x', 2),
W,
image_shape=input_shape,
filter_shape=W_shape,
border_mode='full',
).dimshuffle(0, 1, 3)
input = conved[:, :, shift:input.shape[2] + shift]
conved = T.nnet.conv2d(input.dimshuffle(0, 1, 'x', 2),
W,
image_shape=input_shape,
filter_shape=W_shape,
border_mode='full',
).dimshuffle(0, 1, 3)
input = conved[:, :, shift:input.shape[2] + shift]
output = input
f = theano.function([X], output)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment