Open 3D Engine MachineLearning Gem API Reference  24.09
O3DE is an open-source, fully-featured, high-fidelity, modular 3D engine for building games and simulations, available to every industry.
MachineLearning::Layer Class Reference

A class representing a single layer within a neural network. More...

#include <Layer.h>

Public Member Functions

 AZ_TYPE_INFO (Layer, "{FB91E0A7-86C0-4431-83A8-04F8D8E1C9E2}")
 
 Layer (Layer &&)=default
 
 Layer (const Layer &)=default
 
 Layer (ActivationFunctions activationFunction, AZStd::size_t activationDimensionality, AZStd::size_t layerDimensionality)
 
Layeroperator= (Layer &&)=default
 
Layeroperator= (const Layer &)=default
 
const AZ::VectorN & Forward (LayerInferenceData &inferenceData, const AZ::VectorN &activations)
 Performs a basic forward pass on this layer, outputs are stored in m_output.
 
void AccumulateGradients (AZStd::size_t samples, LayerTrainingData &trainingData, LayerInferenceData &inferenceData, const AZ::VectorN &expected)
 
void ApplyGradients (LayerTrainingData &trainingData, float learningRate)
 Applies the current gradient values to the layers weights and biases and resets the gradient values for a new accumulation pass.
 
bool Serialize (AzNetworking::ISerializer &serializer)
 
AZStd::size_t EstimateSerializeSize () const
 Returns the estimated size required to serialize this layer.
 
void OnSizesChanged ()
 Updates layer internals for it's requested dimensionalities.
 

Static Public Member Functions

static void Reflect (AZ::ReflectContext *context)
 

Public Attributes

AZStd::size_t m_inputSize = 0
 
AZStd::size_t m_outputSize = 0
 
AZ::MatrixMxN m_weights
 
AZ::VectorN m_biases
 
ActivationFunctions m_activationFunction = ActivationFunctions::ReLU
 

Detailed Description

A class representing a single layer within a neural network.

Member Function Documentation

◆ AccumulateGradients()

void MachineLearning::Layer::AccumulateGradients ( AZStd::size_t  samples,
LayerTrainingData trainingData,
LayerInferenceData inferenceData,
const AZ::VectorN &  expected 
)

Performs a gradient computation against the provided expected output using the provided gradients from the previous layer. This method presumes that we've completed a forward pass immediately prior to fill all the relevant vectors

◆ Reflect()

static void MachineLearning::Layer::Reflect ( AZ::ReflectContext *  context)
static

AzCore Reflection.

Parameters
contextreflection context

◆ Serialize()

bool MachineLearning::Layer::Serialize ( AzNetworking::ISerializer &  serializer)

Base serialize method for all serializable structures or classes to implement.

Parameters
serializerISerializer instance to use for serialization
Returns
boolean true for success, false for serialization failure

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