OpenNN
Open-source neural networks library
Loading...
Searching...
No Matches
opennn::PoolOp Struct Reference

2D pooling operator supporting max and average reductions. More...

#include <operators.h>

Inheritance diagram for opennn::PoolOp:
[legend]

Public Types

enum  Method { Max , Average }
 Supported pooling reductions. More...
 

Public Member Functions

void set (Index input_h, Index input_w, Index input_c, Index pool_h, Index pool_w, Index row_stride, Index column_stride, Index padding_h, Index padding_w, Method method)
 Configures the pooling geometry.
 
void destroy_cuda () override
 Releases CUDA resources owned by the operator; called from destructors.
 
 ~PoolOp () override
 
 PoolOp ()=default
 
 PoolOp (const PoolOp &)=delete
 
PoolOpoperator= (const PoolOp &)=delete
 
void forward_propagate (ForwardPropagation &fp, size_t layer, bool is_training) noexcept override
 Runs the operator's forward computation.
 
void back_propagate (ForwardPropagation &fp, BackPropagation &bp, size_t layer) const noexcept override
 Runs the operator's backward computation, accumulating into gradient/delta buffers.
 
- Public Member Functions inherited from opennn::Operator
virtual ~Operator ()=default
 
virtual vector< TensorSpecparameter_specs () const
 Returns the tensor specs of trainable parameters owned by this operator.
 
virtual vector< TensorSpecstate_specs () const
 Returns the tensor specs of persistent state owned by this operator.
 
virtual void link_parameters (span< const TensorView >)
 Binds parameter views provided by the hosting layer.
 
virtual void link_gradients (span< const TensorView >)
 Binds gradient views provided by the hosting layer.
 
virtual void link_states (span< const TensorView >)
 Binds state views provided by the hosting layer.
 
virtual void set_parameters_random ()
 Initializes parameters with random values.
 
virtual void set_parameters_glorot ()
 Initializes parameters using Glorot (Xavier) initialization.
 
virtual void to_JSON (JsonWriter &) const
 Serializes the operator configuration to a JSON writer.
 
virtual void from_JSON (const Json *)
 Restores the operator configuration from a JSON node.
 
virtual void load_state_from_JSON (const Json *)
 Restores persistent state (e.g. running statistics) from a JSON node.
 
TensorViewget_input (ForwardPropagation &fp, size_t layer, size_t i=0) const noexcept
 
vector< TensorView > & get_inputs (ForwardPropagation &fp, size_t layer, size_t i=0) const noexcept
 
TensorViewget_output (ForwardPropagation &fp, size_t layer, size_t i=0) const noexcept
 
TensorViewget_output_delta (BackPropagation &bp, size_t layer, size_t i=0) const noexcept
 
TensorViewget_input_delta (BackPropagation &bp, size_t layer, size_t i=0) const noexcept
 

Public Attributes

Index input_height = 0
 
Index input_width = 0
 
Index input_channels = 0
 
Index pool_height = 1
 
Index pool_width = 1
 
Index row_stride = 1
 
Index column_stride = 1
 
Index padding_height = 0
 
Index padding_width = 0
 
Method method = Max
 
- Public Attributes inherited from opennn::Operator
vector< size_t > input_slots = {0}
 
vector< size_t > output_slots = {1}
 
vector< size_t > input_delta_slots = {1}
 
vector< size_t > output_delta_slots = {0}
 

Detailed Description

2D pooling operator supporting max and average reductions.

Member Enumeration Documentation

◆ Method

Supported pooling reductions.

Enumerator
Max 
Average 

Constructor & Destructor Documentation

◆ ~PoolOp()

opennn::PoolOp::~PoolOp ( )
inlineoverride

◆ PoolOp() [1/2]

opennn::PoolOp::PoolOp ( )
default

◆ PoolOp() [2/2]

opennn::PoolOp::PoolOp ( const PoolOp & )
delete

Member Function Documentation

◆ back_propagate()

void opennn::PoolOp::back_propagate ( ForwardPropagation & fp,
BackPropagation & bp,
size_t layer ) const
overridevirtualnoexcept

Runs the operator's backward computation, accumulating into gradient/delta buffers.

Parameters
fpForward propagation workspace (read-only).
bpBack propagation workspace receiving gradients and deltas.
layerIndex of the hosting layer in the workspace.

Reimplemented from opennn::Operator.

◆ destroy_cuda()

void opennn::PoolOp::destroy_cuda ( )
overridevirtual

Releases CUDA resources owned by the operator; called from destructors.

Reimplemented from opennn::Operator.

◆ forward_propagate()

void opennn::PoolOp::forward_propagate ( ForwardPropagation & fp,
size_t layer,
bool is_training )
overridevirtualnoexcept

Runs the operator's forward computation.

Parameters
fpForward propagation workspace.
layerIndex of the hosting layer in the workspace.
is_trainingIf true, enables training-only behavior (e.g. dropout sampling).

Reimplemented from opennn::Operator.

◆ operator=()

PoolOp & opennn::PoolOp::operator= ( const PoolOp & )
delete

◆ set()

void opennn::PoolOp::set ( Index input_h,
Index input_w,
Index input_c,
Index pool_h,
Index pool_w,
Index row_stride,
Index column_stride,
Index padding_h,
Index padding_w,
Method method )

Configures the pooling geometry.

Parameters
input_hInput height in pixels.
input_wInput width in pixels.
input_cNumber of input channels.
pool_hPooling window height.
pool_wPooling window width.
row_strideVertical stride.
column_strideHorizontal stride.
padding_hVertical padding.
padding_wHorizontal padding.
methodReduction method (Max or Average).

Member Data Documentation

◆ column_stride

Index opennn::PoolOp::column_stride = 1

◆ input_channels

Index opennn::PoolOp::input_channels = 0

◆ input_height

Index opennn::PoolOp::input_height = 0

◆ input_width

Index opennn::PoolOp::input_width = 0

◆ method

Method opennn::PoolOp::method = Max

◆ padding_height

Index opennn::PoolOp::padding_height = 0

◆ padding_width

Index opennn::PoolOp::padding_width = 0

◆ pool_height

Index opennn::PoolOp::pool_height = 1

◆ pool_width

Index opennn::PoolOp::pool_width = 1

◆ row_stride

Index opennn::PoolOp::row_stride = 1