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

Workspace holding parameter gradients and per-layer deltas during a backward pass. More...

#include <back_propagation.h>

Public Member Functions

 BackPropagation (const Index=0, Loss *=nullptr)
 Constructs a workspace for the given batch size and loss.
 
virtual ~BackPropagation ()=default
 
void set (const Index=0, Loss *=nullptr)
 Reconfigures the workspace for a new batch size or loss; reuses allocations when possible.
 
void accumulate_output_deltas (size_t layer_index)
 Accumulates deltas from all consumer edges into the given layer's output delta.
 
TensorViewget_output_delta ()
 Returns the output delta of the network (gradient w.r.t. the final outputs).
 
const TensorViewget_output_delta () const
 Returns the output delta of the network (gradient w.r.t. the final outputs).
 
void print () const
 Prints a human-readable summary of the workspace contents.
 

Public Attributes

const NeuralNetworkneural_network = nullptr
 
Buffer gradient
 
vector< vector< TensorView > > gradient_views
 
Buffer delta_pool
 
vector< vector< TensorView > > delta_views
 
vector< vector< pair< size_t, size_t > > > consumer_edges
 
Index batch_size = 0
 
Lossloss = nullptr
 
float error = 0.0f
 
float accuracy = 0.0f
 
float loss_value = 0.0f
 
Index active_tokens_count = 0
 

Detailed Description

Workspace holding parameter gradients and per-layer deltas during a backward pass.

Constructor & Destructor Documentation

◆ BackPropagation()

opennn::BackPropagation::BackPropagation ( const Index = 0,
Loss * = nullptr )

Constructs a workspace for the given batch size and loss.

Parameters
batch_sizeMaximum number of samples per backward pass.
lossLoss object whose network drives buffer sizing (non-owning).

◆ ~BackPropagation()

virtual opennn::BackPropagation::~BackPropagation ( )
virtualdefault

Member Function Documentation

◆ accumulate_output_deltas()

void opennn::BackPropagation::accumulate_output_deltas ( size_t layer_index)

Accumulates deltas from all consumer edges into the given layer's output delta.

Parameters
layer_indexIndex of the layer whose output delta is being collected.

◆ get_output_delta() [1/2]

TensorView & opennn::BackPropagation::get_output_delta ( )

Returns the output delta of the network (gradient w.r.t. the final outputs).

◆ get_output_delta() [2/2]

const TensorView & opennn::BackPropagation::get_output_delta ( ) const

Returns the output delta of the network (gradient w.r.t. the final outputs).

◆ print()

void opennn::BackPropagation::print ( ) const

Prints a human-readable summary of the workspace contents.

◆ set()

void opennn::BackPropagation::set ( const Index = 0,
Loss * = nullptr )

Reconfigures the workspace for a new batch size or loss; reuses allocations when possible.

Parameters
batch_sizeMaximum number of samples per backward pass.
lossLoss object whose network drives buffer sizing (non-owning).

Member Data Documentation

◆ accuracy

float opennn::BackPropagation::accuracy = 0.0f

◆ active_tokens_count

Index opennn::BackPropagation::active_tokens_count = 0

◆ batch_size

Index opennn::BackPropagation::batch_size = 0

◆ consumer_edges

vector<vector<pair<size_t, size_t> > > opennn::BackPropagation::consumer_edges

◆ delta_pool

Buffer opennn::BackPropagation::delta_pool

◆ delta_views

vector<vector<TensorView> > opennn::BackPropagation::delta_views

◆ error

float opennn::BackPropagation::error = 0.0f

◆ gradient

Buffer opennn::BackPropagation::gradient

◆ gradient_views

vector<vector<TensorView> > opennn::BackPropagation::gradient_views

◆ loss

Loss* opennn::BackPropagation::loss = nullptr

◆ loss_value

float opennn::BackPropagation::loss_value = 0.0f

◆ neural_network

const NeuralNetwork* opennn::BackPropagation::neural_network = nullptr