ML functions
 
Loading...
Searching...
No Matches
BatchNorm1D Class Reference

A class that implements 1D batch normalization, inheriting from MLFunction. More...

#include <BatchNorm.h>

Inheritance diagram for BatchNorm1D:
MLFunction

Public Member Functions

 BatchNorm1D (float *weights, float *bias, int numDims, float eps=1e-05)
 Constructor that initializes the batch normalization operation with weights, biases, and dimensions.
 
void apply (const SelectivityVector &rows, std::vector< VectorPtr > &args, const TypePtr &type, exec::EvalCtx &context, VectorPtr &output) const override
 Applies 1D batch normalization to the input array.
 
float * getTensor () const override
 Returns the tensor associated with this function.
 
float * getWeight ()
 Returns the weights of the batch normalization.
 
float * getBias ()
 Returns the biases of the batch normalization.
 
std::string getWeightsFile ()
 Returns the path to the weights file.
 
void setWeights (float *weights)
 Sets the weights for the batch normalization.
 
CostEstimate getCost (std::vector< int > inputDims)
 Estimates the computational cost of applying batch normalization.
 
- Public Member Functions inherited from MLFunction
virtual ~MLFunction ()=default
 Virtual destructor.
 
virtual std::vector< int > getDims ()
 Returns the dimensions of the function.
 
virtual std::string getFuncName ()
 Returns the name of the function.
 
virtual int getNumDims ()
 Returns the number of dimensions of the function.
 

Static Public Member Functions

static std::vector< std::shared_ptr< exec::FunctionSignature > > signatures ()
 Returns the function signatures supported by this class.
 
static std::string getName ()
 Returns the name of the function.
 

Additional Inherited Members

- Protected Member Functions inherited from MLFunction
double getWeightedCost (std::string name, float cost)
 Calculates the weighted cost of the function.
 
std::vector< double > getCoefficientVector (std::string name)
 Retrieves the cost coefficients for the function.
 
- Protected Attributes inherited from MLFunction
std::vector< int > dims
 Dimensions of the function.
 

Detailed Description

A class that implements 1D batch normalization, inheriting from MLFunction.

This class provides functionality to apply 1D batch normalization to an input array. Batch normalization normalizes the input by subtracting the mean and dividing by the standard deviation, then scales and shifts the result using learned weights and biases.

Constructor & Destructor Documentation

◆ BatchNorm1D()

BatchNorm1D::BatchNorm1D ( float * weights,
float * bias,
int numDims,
float eps = 1e-05 )
inline

Constructor that initializes the batch normalization operation with weights, biases, and dimensions.

Parameters
weightsA pointer to the weight matrix for scaling.
biasA pointer to the bias vector for shifting.
numDimsThe number of dimensions (features) in the input.
epsA small value added to the variance to avoid division by zero (default: 1e-05).

Member Function Documentation

◆ apply()

void BatchNorm1D::apply ( const SelectivityVector & rows,
std::vector< VectorPtr > & args,
const TypePtr & type,
exec::EvalCtx & context,
VectorPtr & output ) const
inlineoverride

Applies 1D batch normalization to the input array.

This method processes the input array, applies batch normalization, and stores the result in the output vector.

Parameters
rowsA SelectivityVector specifying the rows to process.
argsA vector of input arguments (e.g., the input array).
typeThe type of the output vector.
contextThe execution context.
outputThe output vector where the result will be stored.

◆ getBias()

float * BatchNorm1D::getBias ( )
inline

Returns the biases of the batch normalization.

Returns
A pointer to the bias vector.

◆ getCost()

CostEstimate BatchNorm1D::getCost ( std::vector< int > inputDims)
inlinevirtual

Estimates the computational cost of applying batch normalization.

Parameters
inputDimsA vector containing the dimensions of the input.
Returns
A CostEstimate object representing the estimated cost.

Reimplemented from MLFunction.

◆ getName()

static std::string BatchNorm1D::getName ( )
inlinestatic

Returns the name of the function.

Returns
The name of the function as a string.

◆ getTensor()

float * BatchNorm1D::getTensor ( ) const
inlineoverridevirtual

Returns the tensor associated with this function.

Returns
A pointer to the weight matrix.

Implements MLFunction.

◆ getWeight()

float * BatchNorm1D::getWeight ( )
inline

Returns the weights of the batch normalization.

Returns
A pointer to the weight matrix.

◆ getWeightsFile()

std::string BatchNorm1D::getWeightsFile ( )
inline

Returns the path to the weights file.

Returns
The path to the weights file as a string.

◆ setWeights()

void BatchNorm1D::setWeights ( float * weights)
inline

Sets the weights for the batch normalization.

Parameters
weightsA pointer to the new weight matrix.

◆ signatures()

static std::vector< std::shared_ptr< exec::FunctionSignature > > BatchNorm1D::signatures ( )
inlinestatic

Returns the function signatures supported by this class.

Returns
A vector of shared pointers to FunctionSignature objects.

The documentation for this class was generated from the following file: