Pooling layers¶
Pooling layers
MaxPooling2D |
Pooling using the max operation |
-
class
braid.berry.layers.
MaxPooling2D
(incoming, kernel_size, stride=1, pad='VALID', **kwargs)¶ Pooling using the
max
operationThis is used to subsample the output from convolutional layers. It works by convolving a kernel with a
max
operation across the activation of the previous layer. More specifically, it looks at a receptive field equal to[1, kernel_size, kernel_size, 1]
and outputs themax
value of the activations in this region, shifting then bystride
amount and repeating.- incoming :
- Parent layer, whose output is given as input to the current layer.
- kernel_size : int
- The size of the kernel to consider for pooling.
- stride : int, optional (default = 1)
- The amount of subsample.
- pad : string, optional (default = “VALID”)
- Type of padding to apply to the input layer before doing pooling.
Expected values - “VALID”, “SAME”. No padding is applied for “VALID”,
while a padding of
(kernel_size + 1) / 2
if “SAME”. This ensures that the output layer shape is the same as that of the input layer shape. - name : string, optional (default = None)
- Name of the layer. Should be specified for better readability (
inherited from
Layer
).
Layer
ortf.Tensor
- input_layer :
- Input layer to this layer.
- input_shape : tuple
- Shape of the incoming layer.
- output :
- The Tensor obtained after performing the transformation applied by this layer.
- output_shape : tuple
- Shape of the output tensor.
- type : string
- Return the name of the class.
Layer
ortf.Tensor
tf.Tensor
See also
Inherits class
Layer
.-
get_output_for
()¶ Perform the max pooling operation and return the output
tf.Tensor
.tf.Tensor
- Output tensor of this layer.
-
get_output_shape_for
(input_shape)¶ Shape of the output tensor after performing MaxPooling.
- input_shape : tuple or list
- Shape of the input layer.
- tuple
- Shape of the output tensor.
Note
Each dimension of the output is given as
\[l_o = \frac{( W - F +2P)}{S} + 1\]where \(W\) is the width of the input layer dim, \(F\) is the
kernel_size
, \(P\) is the amount of padding applied and \(S\) is thestride
.
-
validate_input_layer
(incoming)¶ Validate the input layer dimensions.
Valid input layer would be 4D.
- incoming :
- Parent layer, whose output is given as input to the current layer.
Layer
ortf.Tensor
- bool
True
if connection is valid or raises anexceptions.AssertionError
.