def __init__(self, input_shape, output_shape,
kernel_shape=(2, 2), pool_mode='max', stride=(2, 2), padding = (0,0)):
"""
This function initializes the class.
Input is 4D tensor, output is 4D tensor.
Parameters
----------
input_shape: tuple
a tuple of three values, i.e., (input channel, input width, input height).
output_shape: tuple
a tuple of three values, i.e., (output channel, output width, output height).
output width and height should be match to real convolution output.
kernel_shape: tuple, default: (2, 2)
a tuple of two values, i.e., (kernel width, kernel height).
pool_mode: string {'max', 'sum', 'average_inc_pad', 'average_exc_pad'}, default: 'max'
a string to determine which mode theano pooling will use.
'max': max pooling
'sum': sum pooling
'average_inc_pad': average pooling contains padding
'average_exc_pad': average pooling does not contain padding
'half': pad input with (kernel width //2, kernel height //2) symmetrically and do 'valid'.
if kernel width and height is odd number, output = input
int: pad input with (int, int) symmetrically.
(int1, int2): pad input with (int1, int2) symmetrically.
stride: tuple, default: (1,1)
a tuple of two value, i.e., (stride width, stride height).
also known as subsample.
padding: tuple, default: (0, 0)
a tuple of two value, i.e., (padding updown, padding leftright).
a symmetric padding. padding first, pooling second.
"""
super(Pooling3DLayer, self).__init__()
# check asserts
assert isinstance(input_shape, tuple) and len(input_shape) == 3, '"input_shape" should be a tuple with three values.'
assert isinstance(output_shape, tuple) and len(output_shape) == 3, '"output_shape" should be a tuple with three values.'
assert isinstance(kernel_shape, tuple) and len(kernel_shape) == 2, '"kernel_shape" should be a tuple with two values.'
assert isinstance(stride, tuple) and len(stride) == 2, '"stride" should be a tuple with two values.'
assert isinstance(padding, tuple) and len(padding) == 2, '"padding" should be a tuple with two values.'
assert pool_mode in ['max', 'sum', 'average_inc_pad', 'average_exc_pad'], '"poolmode should be a string mode. see theano.tensor.signal.pool.pool_2d for details.'
# set members
self.input_shape = input_shape
self.output_shape = output_shape
self.kernel_shape = kernel_shape
self.pool_mode = pool_mode
self.stride = stride
self.padding = padding
评论列表
文章目录