Neuron Net
Public Member Functions | Static Public Attributes | Protected Member Functions | Protected Attributes | List of all members
CNeuronLSTM Class Reference

Class of recurrent LSTM unit. More...

Inheritance diagram for CNeuronLSTM:
CNeuronProof CNeuronBase

Public Member Functions

 CNeuronLSTM (void)
 Constructor. More...
 
 ~CNeuronLSTM (void)
 Destructor. More...
 
virtual bool Init (uint numOutputs, uint myIndex, int window, int step, int units_count, ENUM_OPTIMIZATION optimization_type)
 Unit initialization method. Detailed description on the link. More...
 
virtual CLayergetOutputLayer (void)
 Method for getting a pointer to the resulting neural layer. Not used in fully connected neural networks. More...
 
virtual bool calcInputGradients (CLayer *prevLayer)
 Method to transfer gradients to previous layer. More...
 
virtual bool calcInputGradients (CNeuronBase *prevNeuron, uint index)
 Method to transfer gradients to neuron in 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 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 transfer gradient to previous layer. More...
 
virtual bool Init (uint numOutputs, uint myIndex, ENUM_OPTIMIZATION optimization_type)
 Method of initialization class. More...
 
virtual bool updateInputWeights (CObject *&SourceObject)
 Dispatch method for defining the subroutine for updating weights. More...
 
virtual void SetActivationFunction (ENUM_ACTIVATION value)
 Set the type of activation function (ENUM_ACTIVATION) More...
 
virtual void setOutputVal (double val)
 Set the output value. More...
 
virtual double getOutputVal ()
 Return result of feed forward operations. More...
 
virtual double getPrevVal ()
 Return result of feed forward operations at previous iteration. More...
 
virtual void setGradient (double val)
 Set gradient value to neuron. More...
 
virtual double getGradient ()
 Return gradient of neuron. More...
 
virtual CArrayCongetConnections ()
 Method to get access to array of connections. More...
 
virtual double activationFunctionDerivative (double x)
 Calculate derivative of activation function. More...
 
virtual double SigmoidFunctionDerivative (double x)
 Calculate derivative of Sigmoid function. More...
 
virtual double TanhFunctionDerivative (double x)
 Calculate derivative of \(tanh(x)\). More...
 

Static Public Attributes

static double alpha =0.8
 Multiplier to momentum in SGD optimization. More...
 

Protected Member Functions

virtual bool feedForward (CLayer *prevLayer)
 Feed Forward method. Detailed description on the link. More...
 
virtual bool calcHiddenGradients (CLayer *&nextLayer)
 Method to transfer gradient to previous layer. More...
 
virtual bool updateInputWeights (CLayer *&prevLayer)
 Method for updating weights. More...
 
virtual bool updateInputWeights (CLayer *gate, CArrayDouble *input_data)
 Method for updating gates' weights. More...
 
virtual bool InitLayer (CLayer *layer, int numUnits, int numOutputs, ENUM_OPTIMIZATION optimization_type)
 Method of gate initialization. More...
 
virtual CArrayDouble * CalculateGate (CLayer *gate, CArrayDouble *sequence)
 Method of calculation gate iteration. More...
 
virtual double activationFunction (double x)
 Method to calculate activation function. More...
 
virtual double SigmoidFunction (double x)
 Calculating Sigmoid \(\frac{1}{1+e^x}\). More...
 
virtual double TanhFunction (double x)
 Calculating \(tanh(x)\). More...
 

Protected Attributes

CLayerForgetGate
 Object of forget gate. More...
 
CLayerInputGate
 Object of input gate. More...
 
CLayerOutputGate
 Object of output gate. More...
 
CLayerNewContent
 Object of new content. More...
 
CArrayDouble * Memory
 Memory array. More...
 
CArrayDouble * PrevMemory
 Ravious iteration memory array. More...
 
CArrayDouble * Input
 Input data. More...
 
CArrayDouble * InputGradient
 Gradient on previous layer. More...
 
CLayerOutputLayer
 Layer of output data. Used for connection with next layer. More...
 
int iWindow
 Input window size. More...
 
int iStep
 Size of step. More...
 
double outputVal
 Output value. More...
 
double prevVal
 Previous output value. More...
 
uint m_myIndex
 Index of neuron in layer. More...
 
double gradient
 Current gradient of neuron. More...
 
CArrayConConnections
 Array of connections with neurons in next layer. More...
 
ENUM_ACTIVATION activation
 Activation type (ENUM_ACTIVATION) More...
 
ENUM_OPTIMIZATION optimization
 Optimization method (ENUM_OPTIMIZATION) More...
 
int t
 Count of iterations. More...
 

Detailed Description

Class of recurrent LSTM unit.

Detailed description on the link.

Definition at line 2120 of file NeuroNet.mqh.

Constructor & Destructor Documentation

◆ CNeuronLSTM()

CNeuronLSTM::CNeuronLSTM ( void  )

Constructor.

Definition at line 2157 of file NeuroNet.mqh.

◆ ~CNeuronLSTM()

CNeuronLSTM::~CNeuronLSTM ( void  )

Destructor.

Definition at line 2171 of file NeuroNet.mqh.

Member Function Documentation

◆ activationFunction()

double CNeuronBase::activationFunction ( double  x)
protectedvirtualinherited

Method to calculate activation function.

Parameters
xInput data.
Returns
Result of activation function.

Reimplemented in CNeuronConv.

Definition at line 2659 of file NeuroNet.mqh.

◆ activationFunctionDerivative()

double CNeuronBase::activationFunctionDerivative ( double  x)
virtualinherited

Calculate derivative of activation function.

Parameters
[in]xInput data
Returns
Derivative

Reimplemented in CNeuronConv.

Definition at line 2676 of file NeuroNet.mqh.

◆ calcHiddenGradients() [1/2]

bool CNeuronLSTM::calcHiddenGradients ( CLayer *&  nextLayer)
protectedvirtual

Method to transfer gradient to previous layer.

Parameters
nextLayerPointer to next layer.

Reimplemented from CNeuronProof.

Definition at line 2392 of file NeuroNet.mqh.

◆ calcHiddenGradients() [2/2]

bool CNeuronBase::calcHiddenGradients ( CObject *&  TargetObject)
virtualinherited

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

Parameters
TargetObjectPointer to next layer.

Definition at line 955 of file NeuroNet.mqh.

◆ calcInputGradients() [1/2]

bool CNeuronLSTM::calcInputGradients ( CLayer prevLayer)
virtual

Method to transfer gradients to previous layer.

Parameters
[in]prevLayerPointer to previous layer.

Reimplemented from CNeuronProof.

Definition at line 2593 of file NeuroNet.mqh.

◆ calcInputGradients() [2/2]

bool CNeuronLSTM::calcInputGradients ( CNeuronBase prevNeuron,
uint  index 
)
virtual

Method to transfer gradients to neuron in previous layer.

Parameters
[in]prevNeuronPointer to neuron.
[in]indexIndex of neuron in previous layer

Reimplemented from CNeuronProof.

Definition at line 2581 of file NeuroNet.mqh.

◆ CalculateGate()

CArrayDouble * CNeuronLSTM::CalculateGate ( CLayer gate,
CArrayDouble *  sequence 
)
protectedvirtual

Method of calculation gate iteration.

Parameters
[in]gatePointer to gate
[in]sequenceInput data
Returns
Array of output data

Definition at line 2350 of file NeuroNet.mqh.

◆ feedForward() [1/2]

bool CNeuronLSTM::feedForward ( CLayer prevLayer)
protectedvirtual

Feed Forward method. Detailed description on the link.

Parameters
prevLayerPointer to previos layer.

Reimplemented from CNeuronProof.

Definition at line 2258 of file NeuroNet.mqh.

◆ feedForward() [2/2]

bool CNeuronBase::feedForward ( CObject *&  SourceObject)
virtualinherited

Dispatch method for defining the subroutine for Feed Forward process.

Parameters
SourceObjectPointer to previos layer.

Definition at line 855 of file NeuroNet.mqh.

◆ getConnections()

virtual CArrayCon* CNeuronBase::getConnections ( )
inlinevirtualinherited

Method to get access to array of connections.

Returns
Pointer to connections array

Definition at line 439 of file NeuroNet.mqh.

◆ getGradient()

virtual double CNeuronBase::getGradient ( )
inlinevirtualinherited

Return gradient of neuron.

Returns
Gradient

Definition at line 438 of file NeuroNet.mqh.

◆ getOutputLayer()

virtual CLayer* CNeuronLSTM::getOutputLayer ( void  )
inlinevirtual

Method for getting a pointer to the resulting neural layer. Not used in fully connected neural networks.

Returns
Pointer to layer.

Reimplemented from CNeuronProof.

Definition at line 2146 of file NeuroNet.mqh.

◆ getOutputVal()

virtual double CNeuronBase::getOutputVal ( )
inlinevirtualinherited

Return result of feed forward operations.

Returns
Output value

Definition at line 435 of file NeuroNet.mqh.

◆ getPrevVal()

virtual double CNeuronBase::getPrevVal ( )
inlinevirtualinherited

Return result of feed forward operations at previous iteration.

Returns
Previous output value

Definition at line 436 of file NeuroNet.mqh.

◆ Init() [1/2]

bool CNeuronBase::Init ( uint  numOutputs,
uint  myIndex,
ENUM_OPTIMIZATION  optimization_type 
)
virtualinherited

Method of initialization class.

Parameters
numOutputsNumber of connections to next layer.
myIndexIndex of neuron in layer.
optimization_typeOptimization type (ENUM_OPTIMIZATION)
Returns
Boolen result of operations.

Definition at line 484 of file NeuroNet.mqh.

◆ Init() [2/2]

bool CNeuronLSTM::Init ( uint  numOutputs,
uint  myIndex,
int  window,
int  step,
int  units_count,
ENUM_OPTIMIZATION  optimization_type 
)
virtual

Unit initialization method. Detailed description on the link.

Reimplemented from CNeuronProof.

Definition at line 2193 of file NeuroNet.mqh.

◆ InitLayer()

bool CNeuronLSTM::InitLayer ( CLayer layer,
int  numUnits,
int  numOutputs,
ENUM_OPTIMIZATION  optimization_type 
)
protectedvirtual

Method of gate initialization.

Parameters
[in]layerPointer to gate
[in]numUnitsNumber of units in gate
[in]numOutputsNumber of outputs
[in]optimization_typeType of optimization (ENUM_OPTIMIZATION)

Definition at line 2228 of file NeuroNet.mqh.

◆ Load()

bool CNeuronLSTM::Load ( int const  file_handle)
virtual

Load method.

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

Reimplemented from CNeuronProof.

Definition at line 2639 of file NeuroNet.mqh.

◆ Save()

bool CNeuronLSTM::Save ( int const  file_handle)
virtual

Save method.

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

Reimplemented from CNeuronProof.

Definition at line 2619 of file NeuroNet.mqh.

◆ SetActivationFunction()

virtual void CNeuronBase::SetActivationFunction ( ENUM_ACTIVATION  value)
inlinevirtualinherited

Set the type of activation function (ENUM_ACTIVATION)

Definition at line 429 of file NeuroNet.mqh.

◆ setGradient()

virtual void CNeuronBase::setGradient ( double  val)
inlinevirtualinherited

Set gradient value to neuron.

Definition at line 437 of file NeuroNet.mqh.

◆ setOutputVal()

virtual void CNeuronBase::setOutputVal ( double  val)
inlinevirtualinherited

Set the output value.

Definition at line 434 of file NeuroNet.mqh.

◆ SigmoidFunction()

virtual double CNeuronBase::SigmoidFunction ( double  x)
inlineprotectedvirtualinherited

Calculating Sigmoid \(\frac{1}{1+e^x}\).

Parameters
xInput data.
Returns
Result of calculation

Definition at line 422 of file NeuroNet.mqh.

◆ SigmoidFunctionDerivative()

virtual double CNeuronBase::SigmoidFunctionDerivative ( double  x)
inlinevirtualinherited

Calculate derivative of Sigmoid function.

Parameters
xInput data
Returns
Derivative

Definition at line 441 of file NeuroNet.mqh.

◆ TanhFunction()

virtual double CNeuronBase::TanhFunction ( double  x)
inlineprotectedvirtualinherited

Calculating \(tanh(x)\).

Parameters
xInput data.
Returns
Result of calculation

Definition at line 423 of file NeuroNet.mqh.

◆ TanhFunctionDerivative()

virtual double CNeuronBase::TanhFunctionDerivative ( double  x)
inlinevirtualinherited

Calculate derivative of \(tanh(x)\).

Parameters
xInput data
Returns
Derivative

Definition at line 442 of file NeuroNet.mqh.

◆ Type()

virtual int CNeuronLSTM::Type ( void  ) const
inlinevirtual

Identificator of class.

Returns
Type of class

Reimplemented from CNeuronProof.

Definition at line 2152 of file NeuroNet.mqh.

◆ updateInputWeights() [1/3]

bool CNeuronLSTM::updateInputWeights ( CLayer *&  prevLayer)
protectedvirtual

Method for updating weights.

Parameters
prevLayerPointer to previos layer.

Reimplemented from CNeuronBase.

Definition at line 2527 of file NeuroNet.mqh.

◆ updateInputWeights() [2/3]

bool CNeuronLSTM::updateInputWeights ( CLayer gate,
CArrayDouble *  input_data 
)
protectedvirtual

Method for updating gates' weights.

Parameters
gatePointer to gate.
input_dataPointer to tensor with input data.

Definition at line 2543 of file NeuroNet.mqh.

◆ updateInputWeights() [3/3]

bool CNeuronBase::updateInputWeights ( CObject *&  SourceObject)
virtualinherited

Dispatch method for defining the subroutine for updating weights.

Parameters
SourceObjectPointer to previos layer.

Definition at line 883 of file NeuroNet.mqh.

Member Data Documentation

◆ activation

ENUM_ACTIVATION CNeuronBase::activation
protectedinherited

Activation type (ENUM_ACTIVATION)

Definition at line 414 of file NeuroNet.mqh.

◆ alpha

double CNeuronBase::alpha =0.8
staticinherited

Multiplier to momentum in SGD optimization.

Definition at line 432 of file NeuroNet.mqh.

◆ Connections

CArrayCon* CNeuronBase::Connections
protectedinherited

Array of connections with neurons in next layer.

Definition at line 413 of file NeuroNet.mqh.

◆ ForgetGate

CLayer* CNeuronLSTM::ForgetGate
protected

Object of forget gate.

Definition at line 2123 of file NeuroNet.mqh.

◆ gradient

double CNeuronBase::gradient
protectedinherited

Current gradient of neuron.

Definition at line 412 of file NeuroNet.mqh.

◆ Input

CArrayDouble* CNeuronLSTM::Input
protected

Input data.

Definition at line 2129 of file NeuroNet.mqh.

◆ InputGate

CLayer* CNeuronLSTM::InputGate
protected

Object of input gate.

Definition at line 2124 of file NeuroNet.mqh.

◆ InputGradient

CArrayDouble* CNeuronLSTM::InputGradient
protected

Gradient on previous layer.

Definition at line 2130 of file NeuroNet.mqh.

◆ iStep

int CNeuronProof::iStep
protectedinherited

Size of step.

Definition at line 808 of file NeuroNet.mqh.

◆ iWindow

int CNeuronProof::iWindow
protectedinherited

Input window size.

Definition at line 807 of file NeuroNet.mqh.

◆ m_myIndex

uint CNeuronBase::m_myIndex
protectedinherited

Index of neuron in layer.

Definition at line 411 of file NeuroNet.mqh.

◆ Memory

CArrayDouble* CNeuronLSTM::Memory
protected

Memory array.

Definition at line 2127 of file NeuroNet.mqh.

◆ NewContent

CLayer* CNeuronLSTM::NewContent
protected

Object of new content.

Definition at line 2126 of file NeuroNet.mqh.

◆ optimization

ENUM_OPTIMIZATION CNeuronBase::optimization
protectedinherited

Optimization method (ENUM_OPTIMIZATION)

Definition at line 415 of file NeuroNet.mqh.

◆ OutputGate

CLayer* CNeuronLSTM::OutputGate
protected

Object of output gate.

Definition at line 2125 of file NeuroNet.mqh.

◆ OutputLayer

CLayer* CNeuronProof::OutputLayer
protectedinherited

Layer of output data. Used for connection with next layer.

Definition at line 806 of file NeuroNet.mqh.

◆ outputVal

double CNeuronBase::outputVal
protectedinherited

Output value.

Definition at line 409 of file NeuroNet.mqh.

◆ PrevMemory

CArrayDouble* CNeuronLSTM::PrevMemory
protected

Ravious iteration memory array.

Definition at line 2128 of file NeuroNet.mqh.

◆ prevVal

double CNeuronBase::prevVal
protectedinherited

Previous output value.

Definition at line 410 of file NeuroNet.mqh.

◆ t

int CNeuronBase::t
protectedinherited

Count of iterations.

Definition at line 416 of file NeuroNet.mqh.


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