MaxPool2D¶
-
class
MaxPool2D(kernel_size: int, stride: int = None)¶ Bases:
bluebird.layers.layer.LayerApplies a 2D max pooling.
Example:
conv = MaxPool2D(kernel_size=5) net = NeuralNet([ ... conv, ... ])
-
__init__(kernel_size: int, stride: int = None)¶ Initalize the object.
- Parameters
kernel_size (int) – size of the window
stride (int) – defines how much the window moves, defaults to kernel_size
Methods
__init__(kernel_size[, stride])Initalize the object.
backward(grad)Used to calculate the gradients of weights and biases.
build(input_size)Used to finalize building layers.
create_mask(a)Creates the one hot max mask.
forward(inputs[, training])Called each time the data passes throughout the nework.
Returns params of layer.
-
backward(grad: numpy.ndarray) → numpy.ndarray¶ Used to calculate the gradients of weights and biases.
- Parameters
grad (
Tensor) – gradient from previous layer or loss function.- Returns
Gradient
- Return type
Tensor
-
build(input_size) → None¶ Used to finalize building layers.
Important to note, you should set the input_size for the layer in here. Does not apply to the activation functions, you don’t need implement it in them.
- Parameters
input_size (int) – output size from previous layer
- Raises
NotImplementedError –
-
create_mask(a: numpy.ndarray) → numpy.ndarray¶ Creates the one hot max mask.
- Parameters
a (
Tensor) – tensor you wish to create the mask from- Returns
mask
- Return type
Tensor
-
forward(inputs: numpy.ndarray, training: bool = False) → numpy.ndarray¶ Called each time the data passes throughout the nework.
- Parameters
inputs (
Tensor) – output from the previous layertraining (bool, optional) – set to true during training, and is false when network predicts
- Returns
processed input data
- Return type
Tensor
-
get_params() → Dict¶ Returns params of layer.
- Returns
all params of layer
- Return type
dict
-