Last active
January 11, 2017 21:39
-
-
Save Sentient07/e74f48e82d0e184a49f46827be90ac1f to your computer and use it in GitHub Desktop.
Failing test for variable stride
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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: | |
pool_size = tuple((i + pool_dim -1) // pool_dim for i in input_size) | |
stride_size = tuple((i // pool_dim) for i in input_size) | |
pooled_part = pool_2d(data, pool_size, ignore_border=True, stride=stride_size, padding=(0, 0), mode='max') | |
pooled_part = pooled_part.flatten(3) | |
pooled_data_list.append(pooled_part) | |
return T.concatenate(pooled_data_list, axis=2) | |
# ran_input = np.random.random((1,3,4,4)) | |
# x = theano.shared(ran_input) | |
y = T.tensor4() | |
inp_shape = y.shape | |
data_shape = (1,2,4,4) | |
z = spp_pooling(y, [2], inp_shape) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment