Flatten

class Flatten(input_size: Tuple)

Bases: bluebird.layers.input.Input

Flatten layer is a type of an Input layer. It transforms Tensor with dimensions (n, m) to a Tensor with dimensions of (n*m, 1).

Example:

input = Flatten((5, 10))
net = NeuralNet([
        input,
        ...
    ])
__init__(input_size: Tuple) → None

Initializes the object.

Parameters

input_size (Tuple) – dimensions of a input Tensor

Methods

__init__(input_size)

Initializes the object.

backward(output)

Reshapes Tensor back to (n, m).

build()

Called by the model, before its training step.

forward(inputs[, training])

Called each time the data passes throughout the nework.

get_params()

Returns params of layer.

backward(output: numpy.ndarray) → numpy.ndarray

Reshapes Tensor back to (n, m).

Parameters

grad (Tensor) – gradient from previous layer.

Returns

reshaped Tensor (n. m)

Return type

Tensor

build() → None

Called by the model, before its training step.

Prepares the input size for next layer.

forward(inputs: numpy.ndarray, training: bool = False) → numpy.ndarray

Called each time the data passes throughout the nework.

Parameters
  • inputs (Tensor) – input data to the network

  • training (bool, optional) – set to true during training, and is false when network predicts

Returns

reshaped Tensor (n*m, 1)

Return type

Tensor

get_params() → Dict

Returns params of layer.

Returns

all params of layer

Return type

dict