|
| | Pooling (const Shape &input_shape={2, 2, 1}, const Shape &pool_size={ 2, 2 }, const Shape &strides={ 2, 2 }, const Shape &padding={ 0, 0 }, const string &pooling_method="MaxPooling", const string &label="pooling_layer") |
| | Constructs a Pooling layer.
|
| |
| Shape | get_input_shape () const override |
| | Returns the per-sample input shape (height, width, channels).
|
| |
| Shape | get_output_shape () const override |
| | Returns the per-sample output shape.
|
| |
| Index | get_output_height () const |
| | Output spatial height after applying stride and padding.
|
| |
| Index | get_output_width () const |
| | Output spatial width after applying stride and padding.
|
| |
| Index | get_input_height () const |
| | Configured input height.
|
| |
| Index | get_input_width () const |
| | Configured input width.
|
| |
| Index | get_input_channels () const |
| | Configured input (and output) channel count.
|
| |
| Index | get_pool_height () const |
| | Pool window height in pixels.
|
| |
| Index | get_pool_width () const |
| | Pool window width in pixels.
|
| |
| Index | get_row_stride () const |
| | Vertical stride in pixels.
|
| |
| Index | get_column_stride () const |
| | Horizontal stride in pixels.
|
| |
| Index | get_padding_height () const |
| | Padding rows added on each side.
|
| |
| Index | get_padding_width () const |
| | Padding columns added on each side.
|
| |
| PoolingMethod | get_pooling_method () const |
| | Configured pooling reduction method.
|
| |
| vector< Operator * > | get_operators () override |
| | Returns the single Pool operator that implements this layer.
|
| |
| vector< pair< Shape, Type > > | get_forward_specs (Index batch_size) const override |
| | Specifications of the forward intermediate buffers.
|
| |
| void | set (const Shape &input_shape={ 0, 0, 0 }, const Shape &pool_size={ 1, 1 }, const Shape &strides={ 1, 1 }, const Shape &padding={ 0, 0 }, const string &pooling_method="MaxPooling", const string &label="pooling_layer") |
| | Re-initializes the layer; same arguments as the constructor.
|
| |
| void | set_input_shape (const Shape &) override |
| | Updates the input shape and re-derives the output shape.
|
| |
| void | set_pool_size (Index new_pool_height, Index new_pool_width) |
| | Sets the pool window size.
|
| |
| void | set_row_stride (Index new_row_stride) |
| | Sets the vertical stride.
|
| |
| void | set_column_stride (Index new_column_stride) |
| | Sets the horizontal stride.
|
| |
| void | set_padding_height (Index new_padding_height) |
| | Sets the vertical padding.
|
| |
| void | set_padding_width (Index new_padding_width) |
| | Sets the horizontal padding.
|
| |
| void | set_pooling_method (const string &) |
| | Sets the pooling reduction method by name.
|
| |
| void | back_propagate (ForwardPropagation &, BackPropagation &, size_t) const noexcept override |
| | Routes output-side gradients back to the corresponding input positions (max-index or average) in InputDelta.
|
| |
| void | read_JSON_body (const Json *) override |
| | Reads the layer-specific JSON body (pool size, strides, padding, method) from the given JSON node.
|
| |
| void | write_JSON_body (JsonWriter &) const override |
| | Writes the layer-specific JSON body (pool size, strides, padding, method) to the given JSON writer.
|
| |
| virtual | ~Layer ()=default |
| | Virtual destructor; subclasses are owned via unique_ptr<Layer>.
|
| |
| const string & | get_label () const |
| | Returns the user-assigned label of this layer.
|
| |
| const string & | get_name () const |
| | Returns the canonical type name of this layer.
|
| |
| LayerType | get_type () const |
| | Returns the LayerType enumerator for this layer.
|
| |
| virtual void | set_output_shape (const Shape &) |
| | Sets the per-sample output shape of this layer.
|
| |
| void | set_label (string new_label) |
| | Sets the human-readable label of this layer.
|
| |
| Index | get_parameters_number () const |
| | Total number of trainable parameters in this layer.
|
| |
| virtual vector< pair< Shape, Type > > | get_parameter_specs () const |
| | Specifications of the trainable parameter tensors owned by this layer.
|
| |
| virtual vector< pair< Shape, Type > > | get_state_specs () const |
| | Specifications of the persistent state tensors of this layer.
|
| |
| virtual vector< pair< Shape, Type > > | get_backward_specs (Index batch_size) const |
| | Specifications of the backward intermediate buffers for one batch.
|
| |
| vector< Shape > | get_parameter_shapes () const |
| | Shape-only view of get_parameter_specs().
|
| |
| vector< Shape > | get_state_shapes () const |
| | Shape-only view of get_state_specs().
|
| |
| vector< Shape > | get_forward_shapes (Index b) const |
| | Shape-only view of get_forward_specs() for batch size b.
|
| |
| vector< Shape > | get_backward_shapes (Index b) const |
| | Shape-only view of get_backward_specs() for batch size b.
|
| |
| vector< Type > | get_parameter_dtypes () const |
| | Dtype-only view of get_parameter_specs().
|
| |
| vector< Type > | get_forward_dtypes (Index b) const |
| | Dtype-only view of get_forward_specs() for batch size b.
|
| |
| vector< Type > | get_backward_dtypes (Index b) const |
| | Dtype-only view of get_backward_specs() for batch size b.
|
| |
| virtual Activation::Function | get_output_activation () const |
| | Activation function fused at the end of this layer, if any.
|
| |
| Index | get_inputs_number () const |
| | Total number of scalar inputs per sample (product of input dims).
|
| |
| Index | get_outputs_number () const |
| | Total number of scalar outputs per sample (product of output dims).
|
| |
| virtual void | forward_propagate (ForwardPropagation &fp, size_t layer, bool is_training) noexcept |
| | Forward pass: reads inputs from fp and writes outputs into fp.
|
| |
| virtual void | from_JSON (const JsonDocument &document) |
| | Loads the layer configuration (hyperparameters) from JSON.
|
| |
| virtual void | load_state_from_JSON (const JsonDocument &document) |
| | Loads parameter and state tensors from a JSON document.
|
| |
| virtual void | to_JSON (JsonWriter &writer) const |
| | Writes the layer configuration to JSON.
|
| |
| virtual void | print () const |
| | Prints a human-readable summary of the layer to stdout.
|
| |
| bool | get_is_trainable () const |
| | Whether this layer has trainable parameters.
|
| |
| Type | get_compute_dtype () const |
| | Numerical type used for forward/backward computation.
|
| |
| void | set_compute_dtype (Type new_compute_dtype) |
| | Sets the compute dtype and triggers on_compute_dtype_changed().
|
| |
| virtual void | on_compute_dtype_changed () |
| | Hook invoked after set_compute_dtype() mutates the dtype.
|
| |
| virtual float * | link_parameters (float *pointer) |
| | Wires this layer's parameter TensorViews onto an external buffer.
|
| |
| virtual float * | link_states (float *pointer) |
| | Wires this layer's state TensorViews onto an external buffer.
|
| |
| vector< TensorView > & | get_parameter_views () |
| | Mutable access to this layer's parameter TensorViews.
|
| |
| const vector< TensorView > & | get_parameter_views () const |
| | Read-only access to this layer's parameter TensorViews.
|
| |
| vector< TensorView > & | get_state_views () |
| | Mutable access to this layer's state TensorViews.
|
| |
| const vector< TensorView > & | get_state_views () const |
| | Read-only access to this layer's state TensorViews.
|
| |
| void | redistribute_parameters_to_operators () |
| | Forwards the current parameter views down to each composing Operator.
|
| |
| void | redistribute_parameter_gradients_to_operators (vector< TensorView > &gradient_views) |
| | Forwards externally provided gradient views down to each Operator.
|
| |
| void | redistribute_states_to_operators () |
| | Forwards the current state views down to each composing Operator.
|
| |
2D pooling layer (max or average).
Takes rank-3 inputs (height, width, channels) and produces outputs with the same channel count and reduced spatial dimensions, following the configured pool size, strides and padding. The layer has no trainable parameters.
For max-pooling, the index of the maximum within each window is cached in the ForwardPropagation buffer to enable correct gradient routing in the backward pass.