Pooling layers¶
-
class
dynn.layers.pooling_layers.
MaxPool1D
(kernel_size=None, stride=1)¶ Bases:
dynn.layers.base_layers.BaseLayer
1D max pooling
Parameters: -
__call__
(x, kernel_size=None, stride=None)¶ Max pooling over the first dimension.
This takes either a list of
N
d
-dimensional vectors or aN x d
matrix.The output will be a matrix of dimension
(N - kernel_size + 1) // stride x d
Parameters: - x (
dynet.Expression
) – Input matrix or list of vectors - dim (int, optional) – The reduction dimension (default:
0
) - kernel_size (int, optional) – Kernel size. If this is not specified, the default size specified in the constructor is used.
- stride (int, optional) – Temporal stride. If this is not specified, the default stride specified in the constructor is used.
Returns: Pooled sequence.
Return type: - x (
-
__init__
(kernel_size=None, stride=1)¶ Initialize self. See help(type(self)) for accurate signature.
-
-
class
dynn.layers.pooling_layers.
MaxPool2D
(kernel_size=None, strides=None)¶ Bases:
dynn.layers.base_layers.BaseLayer
2D max pooling.
Parameters: -
__call__
(x, kernel_size=None, strides=None)¶ Max pooling over the first dimension.
If either of the
kernel_size
elements is not specified, the pooling will be done over the full dimension (and the stride is ignored)Parameters: - x (
dynet.Expression
) – Input image (3-d tensor) or matrix. - kernel_size (list, optional) – Size of the pooling kernel. If this is not specified, the default specified in the constructor is used.
- strides (list, optional) – Stride along width/height. If this is not specified, the default specified in the constructor is used.
Returns: Pooled sequence.
Return type: - x (
-
__init__
(kernel_size=None, strides=None)¶ Initialize self. See help(type(self)) for accurate signature.
-
-
class
dynn.layers.pooling_layers.
MeanPool1D
(kernel_size=None, stride=1)¶ Bases:
dynn.layers.base_layers.BaseLayer
1D mean pooling.
The stride and kernel size arguments are here for consistency with
MaxPooling1D
but they are unsupported for now.Parameters: -
__call__
(x, kernel_size=None, stride=None, lengths=None)¶ Mean pooling over the first dimension.
This takes either a list of
N
d
-dimensional vectors or aN x d
matrix.The output will be a matrix of dimension
(N - kernel_size + 1) // stride x d
Parameters: - x (
dynet.Expression
) – Input matrix or list of vectors - dim (int, optional) – The reduction dimension (default:
0
) - kernel_size (int, optional) – Kernel size. If this is not specified, the default size specified in the constructor is used.
- stride (int, optional) – Temporal stride. If this is not specified, the default stride specified in the constructor is used.
Returns: Pooled sequence.
Return type: - x (
-
__init__
(kernel_size=None, stride=1)¶ Initialize self. See help(type(self)) for accurate signature.
-
-
dynn.layers.pooling_layers.
max_pool_dim
(x, d=0, kernel_width=None, stride=1)¶ Efficent max pooling on GPU, assuming x is a matrix or a list of vectors