Neuron Net
Modules | Classes

Describes the process for the Neuron Base. More...

Modules

 Feed Forward proccess kernel
 Describes the forward path process for the Neuron Base.
 
 Gradients Calculation kernels
 Describes the process of gradients calculation for the Neuron Base.
 
 Updating Weights Calculation kernel
 Describes the process of optimization weights for the Neuron Base.
 

Classes

class  CNeuronBaseOCL
 The base class of neuron for GPU calculation. More...
 

Detailed Description

Describes the process for the Neuron Base.

Detailed description on the link.


Class Documentation

◆ CNeuronBaseOCL

class CNeuronBaseOCL

The base class of neuron for GPU calculation.

Detailed description on the link.

Definition at line 2926 of file NeuroNet.mqh.

Inheritance diagram for CNeuronBaseOCL:
CNeuronAttentionOCL CNeuronProofOCL CNeuronConvOCL

Public Member Functions

 CNeuronBaseOCL (void)
 Constructor. More...
 
 ~CNeuronBaseOCL (void)
 Destructor. More...
 
virtual bool Init (uint numOutputs, uint myIndex, COpenCLMy *open_cl, uint numNeurons, ENUM_OPTIMIZATION optimization_type)
 Method of initialization class. More...
 
virtual void SetActivationFunction (ENUM_ACTIVATION value)
 Set the type of activation function (ENUM_ACTIVATION) More...
 
virtual int getOutputIndex (void)
 Get index of output buffer. More...
 
virtual int getPrevOutIndex (void)
 Get index of previous iteration output buffer. More...
 
virtual int getGradientIndex (void)
 Get index of gradient buffer. More...
 
virtual int getWeightsIndex (void)
 Get index of weights matrix buffer. More...
 
virtual int getDeltaWeightsIndex (void)
 Get index of delta weights matrix buffer (SGD) More...
 
virtual int getFirstMomentumIndex (void)
 Get index of first momentum matrix buffer (Adam) More...
 
virtual int getSecondMomentumIndex (void)
 Get index of Second momentum matrix buffer (Adam) More...
 
virtual int getOutputVal (double &values[])
 Get values of output buffer. More...
 
virtual int getOutputVal (CArrayDouble *values)
 Get values of output buffer. More...
 
virtual int getPrevVal (double &values[])
 Get values of previous iteration output buffer. More...
 
virtual int getGradient (double &values[])
 Get values of gradient buffer. More...
 
virtual int getWeights (double &values[])
 Get values of weights matrix buffer. More...
 
virtual int Neurons (void)
 Get number of neurons in layer. More...
 
virtual int Activation (void)
 Get type of activation function. More...
 
virtual int getConnections (void)
 Get number of connections 1 neuron to next layer. More...
 
virtual bool FeedForward (CObject *SourceObject)
 Dispatch method for defining the subroutine for feed forward process. More...
 
virtual bool calcHiddenGradients (CObject *TargetObject)
 Dispatch method for defining the subroutine for transferring the gradient to the previous layer. More...
 
virtual bool Save (int const file_handle)
 Save method. More...
 
virtual bool Load (int const file_handle)
 Load method. More...
 
virtual int Type (void) const
 Identificator of class. More...
 
virtual bool UpdateInputWeights (CObject *SourceObject)
 Dispatch method for defining the subroutine for updating weights. More...
 
virtual bool calcHiddenGradients (CNeuronBaseOCL *NeuronOCL)
 Method to transfer gradient to previous layer by calling kernel CalcHiddenGradient(). More...
 
virtual bool calcOutputGradients (CArrayDouble *Target)
 Method of output gradients calculation by calling kernel CalcOutputGradient(). More...
 

Protected Member Functions

virtual bool feedForward (CNeuronBaseOCL *NeuronOCL)
 Feed Forward method of calling kernel FeedForward(). More...
 
virtual bool updateInputWeights (CNeuronBaseOCL *NeuronOCL)
 

Protected Attributes

COpenCLMyOpenCL
 Object for working with OpenCL. More...
 
CBufferDoubleOutput
 Buffer of Output tenzor. More...
 
CBufferDoublePrevOutput
 Buffer of previous iteration Output tenzor. More...
 
CBufferDoubleWeights
 Buffer of weights matrix. More...
 
CBufferDoubleDeltaWeights
 Buffer of last delta weights matrix (SGD) More...
 
CBufferDoubleGradient
 Buffer of gradient tenzor. More...
 
CBufferDoubleFirstMomentum
 Buffer of first momentum matrix (ADAM) More...
 
CBufferDoubleSecondMomentum
 Buffer of second momentum matrix (ADAM) More...
 
const double alpha
 Multiplier to momentum in SGD optimization. More...
 
int t
 Count of iterations. More...
 
int m_myIndex
 Index of neuron in layer. More...
 
ENUM_ACTIVATION activation
 Activation type (ENUM_ACTIVATION) More...
 
ENUM_OPTIMIZATION optimization
 Optimization method (ENUM_OPTIMIZATION) More...
 

Constructor & Destructor Documentation

◆ CNeuronBaseOCL()

CNeuronBaseOCL::CNeuronBaseOCL ( void  )

Constructor.

Definition at line 2993 of file NeuroNet.mqh.

◆ ~CNeuronBaseOCL()

CNeuronBaseOCL::~CNeuronBaseOCL ( void  )

Destructor.

Definition at line 3010 of file NeuroNet.mqh.

Member Function Documentation

◆ Activation()

virtual int CNeuronBaseOCL::Activation ( void  )
inlinevirtual

Get type of activation function.

Returns
Type (ENUM_ACTIVATION)

Definition at line 2973 of file NeuroNet.mqh.

◆ calcHiddenGradients()

bool CNeuronBaseOCL::calcHiddenGradients ( CObject *  TargetObject)
virtual

Dispatch method for defining the subroutine for transferring the gradient to the previous layer.

Parameters
TargetObjectPointer to the next layer.

Definition at line 3328 of file NeuroNet.mqh.

◆ FeedForward()

bool CNeuronBaseOCL::FeedForward ( CObject *  SourceObject)
virtual

Dispatch method for defining the subroutine for feed forward process.

Parameters
SourceObjectPointer to the previous layer.

Definition at line 3151 of file NeuroNet.mqh.

◆ getConnections()

virtual int CNeuronBaseOCL::getConnections ( void  )
inlinevirtual

Get number of connections 1 neuron to next layer.

Returns
Number of connections

Definition at line 2974 of file NeuroNet.mqh.

◆ getDeltaWeightsIndex()

virtual int CNeuronBaseOCL::getDeltaWeightsIndex ( void  )
inlinevirtual

Get index of delta weights matrix buffer (SGD)

Returns
Index

Definition at line 2963 of file NeuroNet.mqh.

◆ getFirstMomentumIndex()

virtual int CNeuronBaseOCL::getFirstMomentumIndex ( void  )
inlinevirtual

Get index of first momentum matrix buffer (Adam)

Returns
Index

Definition at line 2964 of file NeuroNet.mqh.

◆ getGradient()

virtual int CNeuronBaseOCL::getGradient ( double &  values[])
inlinevirtual

Get values of gradient buffer.

Parameters
[out]valuesArray of data
Returns
number of items

Definition at line 2970 of file NeuroNet.mqh.

◆ getGradientIndex()

virtual int CNeuronBaseOCL::getGradientIndex ( void  )
inlinevirtual

Get index of gradient buffer.

Returns
Index

Definition at line 2961 of file NeuroNet.mqh.

◆ getOutputIndex()

virtual int CNeuronBaseOCL::getOutputIndex ( void  )
inlinevirtual

Get index of output buffer.

Returns
Index

Definition at line 2959 of file NeuroNet.mqh.

◆ getOutputVal() [1/2]

virtual int CNeuronBaseOCL::getOutputVal ( CArrayDouble *  values)
inlinevirtual

Get values of output buffer.

Parameters
[out]valuesArray of data
Returns
number of items

Definition at line 2968 of file NeuroNet.mqh.

◆ getOutputVal() [2/2]

virtual int CNeuronBaseOCL::getOutputVal ( double &  values[])
inlinevirtual

Get values of output buffer.

Parameters
[out]valuesArray of data
Returns
number of items

Definition at line 2967 of file NeuroNet.mqh.

◆ getPrevOutIndex()

virtual int CNeuronBaseOCL::getPrevOutIndex ( void  )
inlinevirtual

Get index of previous iteration output buffer.

Returns
Index

Definition at line 2960 of file NeuroNet.mqh.

◆ getPrevVal()

virtual int CNeuronBaseOCL::getPrevVal ( double &  values[])
inlinevirtual

Get values of previous iteration output buffer.

Parameters
[out]valuesArray of data
Returns
number of items

Definition at line 2969 of file NeuroNet.mqh.

◆ getSecondMomentumIndex()

virtual int CNeuronBaseOCL::getSecondMomentumIndex ( void  )
inlinevirtual

Get index of Second momentum matrix buffer (Adam)

Returns
Index

Definition at line 2965 of file NeuroNet.mqh.

◆ getWeights()

virtual int CNeuronBaseOCL::getWeights ( double &  values[])
inlinevirtual

Get values of weights matrix buffer.

Parameters
[out]valuesArray of data
Returns
number of items

Definition at line 2971 of file NeuroNet.mqh.

◆ getWeightsIndex()

virtual int CNeuronBaseOCL::getWeightsIndex ( void  )
inlinevirtual

Get index of weights matrix buffer.

Returns
Index

Definition at line 2962 of file NeuroNet.mqh.

◆ Init()

bool CNeuronBaseOCL::Init ( uint  numOutputs,
uint  myIndex,
COpenCLMy open_cl,
uint  numNeurons,
ENUM_OPTIMIZATION  optimization_type 
)
virtual

Method of initialization class.

Parameters
[in]numOutputsNumber of connections to next layer.
[in]myIndexIndex of neuron in layer.
[in]open_clPointer to COpenCLMy object. #param[in] numNeurons Number of neurons in layer
optimization_typeOptimization type (ENUM_OPTIMIZATION)
Returns
Boolen result of operations.

Definition at line 3031 of file NeuroNet.mqh.

◆ Load()

bool CNeuronBaseOCL::Load ( int const  file_handle)
virtual

Load method.

Parameters
[in]file_handlehandle of file
Returns
logical result of operation

Reimplemented in CNeuronAttentionOCL, CNeuronConvOCL, and CNeuronProofOCL.

Definition at line 3429 of file NeuroNet.mqh.

◆ Neurons()

virtual int CNeuronBaseOCL::Neurons ( void  )
inlinevirtual

Get number of neurons in layer.

Returns
Number of neurons

Definition at line 2972 of file NeuroNet.mqh.

◆ Save()

bool CNeuronBaseOCL::Save ( int const  file_handle)
virtual

Save method.

Parameters
[in]file_handlehandle of file
Returns
logical result of operation

Reimplemented in CNeuronAttentionOCL, CNeuronConvOCL, and CNeuronProofOCL.

Definition at line 3380 of file NeuroNet.mqh.

◆ SetActivationFunction()

virtual void CNeuronBaseOCL::SetActivationFunction ( ENUM_ACTIVATION  value)
inlinevirtual

Set the type of activation function (ENUM_ACTIVATION)

Definition at line 2957 of file NeuroNet.mqh.

◆ Type()

virtual int CNeuronBaseOCL::Type ( void  ) const
inlinevirtual

Identificator of class.

Returns
Type of class

Reimplemented in CNeuronAttentionOCL, CNeuronConvOCL, and CNeuronProofOCL.

Definition at line 2988 of file NeuroNet.mqh.

Member Data Documentation

◆ activation

ENUM_ACTIVATION CNeuronBaseOCL::activation
protected

Activation type (ENUM_ACTIVATION)

Definition at line 2943 of file NeuroNet.mqh.

◆ alpha

const double CNeuronBaseOCL::alpha
protected

Multiplier to momentum in SGD optimization.

Definition at line 2939 of file NeuroNet.mqh.

◆ DeltaWeights

CBufferDouble* CNeuronBaseOCL::DeltaWeights
protected

Buffer of last delta weights matrix (SGD)

Definition at line 2933 of file NeuroNet.mqh.

◆ FirstMomentum

CBufferDouble* CNeuronBaseOCL::FirstMomentum
protected

Buffer of first momentum matrix (ADAM)

Definition at line 2935 of file NeuroNet.mqh.

◆ Gradient

CBufferDouble* CNeuronBaseOCL::Gradient
protected

Buffer of gradient tenzor.

Definition at line 2934 of file NeuroNet.mqh.

◆ m_myIndex

int CNeuronBaseOCL::m_myIndex
protected

Index of neuron in layer.

Definition at line 2942 of file NeuroNet.mqh.

◆ OpenCL

COpenCLMy* CNeuronBaseOCL::OpenCL
protected

Object for working with OpenCL.

Definition at line 2929 of file NeuroNet.mqh.

◆ optimization

ENUM_OPTIMIZATION CNeuronBaseOCL::optimization
protected

Optimization method (ENUM_OPTIMIZATION)

Definition at line 2944 of file NeuroNet.mqh.

◆ Output

CBufferDouble* CNeuronBaseOCL::Output
protected

Buffer of Output tenzor.

Definition at line 2930 of file NeuroNet.mqh.

◆ PrevOutput

CBufferDouble* CNeuronBaseOCL::PrevOutput
protected

Buffer of previous iteration Output tenzor.

Definition at line 2931 of file NeuroNet.mqh.

◆ SecondMomentum

CBufferDouble* CNeuronBaseOCL::SecondMomentum
protected

Buffer of second momentum matrix (ADAM)

Definition at line 2936 of file NeuroNet.mqh.

◆ t

int CNeuronBaseOCL::t
protected

Count of iterations.

Definition at line 2940 of file NeuroNet.mqh.

◆ Weights

CBufferDouble* CNeuronBaseOCL::Weights
protected

Buffer of weights matrix.

Definition at line 2932 of file NeuroNet.mqh.