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
maxoperationThis is used to subsample the output from convolutional layers. It works by convolving a kernel with a
maxoperation 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 themaxvalue of the activations in this region, shifting then bystrideamount 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) / 2if “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).
Layerortf.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.
Layerortf.Tensortf.TensorSee 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.
Layerortf.Tensor- bool
Trueif connection is valid or raises anexceptions.AssertionError.