panann
|
#include <RecurrentNeuralNetwork.h>
Classes | |
struct | CellLayer |
struct | LongShortTermMemoryCell |
Public Member Functions | |
RecurrentNeuralNetwork (const RecurrentNeuralNetwork &)=delete | |
RecurrentNeuralNetwork & | operator= (const RecurrentNeuralNetwork &)=delete |
void | SetCellMemorySize (size_t memory_size) |
size_t | GetCellMemorySize () const |
void | RunForward (const std::vector< double > &input) override |
std::vector< double > & | GetCellStates () |
void | AddHiddenLayer (size_t neuron_count)=delete |
void | AddHiddenLayer (size_t cell_count, const std::vector< size_t > &cell_memory_sizes={}) |
void | Construct () override |
![]() | |
Perceptron (const Perceptron &)=delete | |
Perceptron & | operator= (const Perceptron &)=delete |
void | SetErrorCostFunction (ErrorCostFunction mode) |
ErrorCostFunction | GetErrorCostFunction () const |
void | SetHiddenNeuronActivationFunctionType (ActivationFunctionType type) |
ActivationFunctionType | GetHiddenNeuronActivationFunctionType () const |
void | SetOutputNeuronActivationFunctionType (ActivationFunctionType type) |
ActivationFunctionType | GetOutputNeuronActivationFunctionType () const |
void | InitializeWeightsRandom (double min=-1.0, double max=1.0) |
void | InitializeWeights (const TrainingData &training_data) |
void | RunBackward (const std::vector< double > &output) |
double | GetError (const std::vector< double > &output) |
double | GetError (const TrainingData &training_data) |
std::vector< double > & | GetWeights () |
void | SetWeights (const std::vector< double > &weights) |
void | GetOutput (std::vector< double > *output) const |
bool | IsConstructed () const |
void | EnableErrorShaping () |
void | DisableErrorShaping () |
![]() | |
MultiLayerNeuralTopology (const MultiLayerNeuralTopology &)=delete | |
MultiLayerNeuralTopology & | operator= (const MultiLayerNeuralTopology &)=delete |
void | AddHiddenLayer (size_t neuron_count) |
void | EnableShortcutConnections () |
void | DisableShortcutConnections () |
void | ConstructTopology () |
bool | IsTopologyConstructed () const |
size_t | GetHiddenLayerCount () const |
const Layer & | GetHiddenLayer (size_t layer_index) const |
size_t | GetInputConnectionCount () const |
size_t | GetOutputConnectionCount () const |
const InputConnection & | GetInputConnection (size_t index) const |
const OutputConnection & | GetOutputConnection (size_t index) const |
![]() | |
NeuronContainer (const NeuronContainer &)=delete | |
NeuronContainer & | operator= (const NeuronContainer &)=delete |
void | SetInputNeuronCount (size_t input_neuron_count) |
size_t | GetInputNeuronCount () const |
void | SetOutputNeuronCount (size_t output_neuron_count) |
size_t | GetOutputNeuronCount () const |
size_t | GetNeuronCount () const |
const Neuron & | GetNeuron (size_t neuron_index) const |
Protected Member Functions | |
void | ConnectFully () override |
void | FixNeuronConnectionIndices () override |
void | InitializeHiddenNeurons () override |
void | AllocateCellStates () |
bool | AreCellStatesAllocated () const |
void | UpdateCellState (const LongShortTermMemoryCell &cell) |
size_t | AddCellMemoryStates (size_t count) |
size_t | GetCellCount () const |
LongShortTermMemoryCell & | GetCell (size_t index) |
size_t | GetCellLayerCount () const |
CellLayer & | GetCellLayer (size_t index) |
void | InitializeCellNeurons (const LongShortTermMemoryCell &cell, size_t input_connection_count, size_t output_connection_count) |
void | InitializeCellNeuronsOneGate (size_t neuron_start_index, size_t neurons_per_gate, ActivationFunctionType activation_function, size_t input_connection_count, size_t output_connection_count) |
![]() | |
void | AllocateWeights () |
bool | AreWeightsAllocated () const |
void | InitializeNeurons () |
void | ComputeNeuronValue (size_t neuron_index) |
void | ComputeNeuronValueRange (size_t neuron_start_index, size_t neuron_count) |
void | ComputeNeuronError (size_t neuron_index) |
void | ResetOutputLayerError () |
void | CalculateOutputLayerError (const std::vector< double > &output) |
double | GetError () const |
RandomWrapper & | GetRandom () |
size_t | GetWeightCount () const |
double & | GetWeight (size_t index) |
![]() | |
Layer & | GetHiddenLayer (size_t layer_index) |
InputConnection & | GetInputConnection (size_t index) |
OutputConnection & | GetOutputConnection (size_t index) |
size_t | AddInputConnections (size_t count) |
size_t | AddOutputConnections (size_t count) |
void | AllocateConnections () |
bool | AreConnectionsAllocated () const |
void | ConnectLayerToNeuron (size_t from_neuron_index, size_t from_neuron_count, size_t to_neuron_index) |
void | ConnectLayers (size_t from_neuron_index, size_t from_neuron_count, size_t to_neuron_index, size_t to_neuron_count) |
void | ConnectBiasNeuron (size_t bias_neuron_index, size_t to_neuron_index, size_t to_neuron_count) |
void | ConnectNeurons (size_t from_neuron_index, size_t to_neuron_index) |
![]() | |
size_t | GetHiddenNeuronStartIndex () const |
size_t | GetInputNeuronStartIndex () const |
size_t | GetOutputNeuronStartIndex () const |
size_t | GetBiasNeuronStartIndex () const |
size_t | GetHiddenNeuronCount () const |
size_t | GetBiasNeuronCount () const |
size_t | AddHiddenNeurons (size_t count) |
void | AddBiasNeurons (size_t count) |
void | AllocateNeurons () |
bool | AreNeuronsAllocated () const |
void | SetNeuronActivationFunction (size_t neuron_index, ActivationFunctionType type) |
Neuron & | GetNeuron (size_t neuron_index) |
Neuron & | GetInputNeuron (size_t input_neuron_index) |
Neuron & | GetOutputNeuron (size_t output_neuron_index) |
Neuron & | GetBiasNeuron (size_t bias_neuron_index) |
Neuron & | GetHiddenNeuron (size_t hidden_neuron_index) |
const Neuron & | GetOutputNeuron (size_t output_neuron_index) const |
Additional Inherited Members | |
![]() | |
enum | ErrorCostFunction : uint8_t { MeanSquareError = 1, MeanAbsoluteError } |
A recurrent artificial neural network made out of long short term memory cells.
This network doesn't contain ordinary hidden neurons organized into layers. Instead, each layer contains a set of recurrent cells which are each made of a number of hidden units grouped into gates.
Note: RecurrentNeuralNetwork does not support any training algorithms, currently.
void panann::RecurrentNeuralNetwork::AddHiddenLayer | ( | size_t | cell_count, |
const std::vector< size_t > & | cell_memory_sizes = {} |
||
) |
Add a hidden layer of LSTM cells.
Each cell may have a different cell memory size passed via |cell_memory_sizes|. If the vector doesn't contain an element for a cell or if that element is 0, the cell memory size for that cell will be the default returned via GetCellMemorySize().
|
overridevirtual |
Build the neural network.
After construction, the network topology may not be modified.
Reimplemented from panann::Perceptron.
|
overrideprotectedvirtual |
Set the input and output connection indices assigned to each neuron into the neurons themselves.
Reimplemented from panann::MultiLayerNeuralTopology.
std::vector< double > & panann::RecurrentNeuralNetwork::GetCellStates | ( | ) |
Get a writable vector of memory state for all cells in the network.
|
protected |
Initialize all the neurons making up |cell|.
Each gate of the cell will be assigned |input_connection_count| input connections (and zero output connections).
The output layer of the cell will be assigned |output_connection_count| output connections (and zero input connections).
|
protected |
Initialize the neurons in one gate of a cell.
|
overrideprotectedvirtual |
Set the default activation function etc for all hidden neurons in the network.
Reimplemented from panann::Perceptron.
|
overridevirtual |
Run the network forward on a set of inputs.
The values computed by running the network will be stored in the output neurons.
Works by assigning the values in the input parameter into each input neuron and pulling those values through the hidden layers, calculating the output of each neuron as the result of executing the activation function on the sum of the incoming values multiplied by their connection weights.
input | Must have the same number of elements as this network has input neurons. |
Reimplemented from panann::Perceptron.
void panann::RecurrentNeuralNetwork::SetCellMemorySize | ( | size_t | memory_size | ) |
Set the number of memory states which each cell will contain by default.
This value has a quadratic effect on the size of the network topology. Increasing the number of cell memory states increases the number of neurons in each cell gate - effectively, increasing this value by one increases the number of hidden neurons in the network topology by 5 per LSTM cell. Default: 200