SANN: Sushi Artificial Neural Network
This is a short library for a simple but efficient neural network
Public Types | Public Member Functions | Static Public Attributes | List of all members
sann::Network Class Reference

This is the core class, that represents the whole Neural Network. More...

#include <Network.hpp>

Collaboration diagram for sann::Network:
Collaboration graph
[legend]

Public Types

typedef std::function< std::vector< double >const std::vector< double > &target, const std::vector< double > &out)> error_func
 

Public Member Functions

 Network ()
 Creates a new empty network.
 
 Network (const std::vector< size_t > &layers, const math::Func &activationFunc, const Layer::weights_initializer &init)
 
 Network (const std::vector< size_t > &layers, const std::vector< math::Func > &activationFuncs, const Layer::weights_initializer &init)
 
 Network (const Network &net)
 Creates a new network equal to an existent one. More...
 
Networkoperator= (const Network &rhs)
 Copy assignment.
 
Networkoperator= (Network &&rhs)
 Move assignment.
 
void setParameters (const sann::parameters &hyperP)
 
void setWeights (const std::vector< std::vector< double >> &weights)
 
void setWeights (const std::vector< weightsMatrix > &weights)
 
void setWeights (std::vector< weightsMatrix > &&weights)
 Sets the weights for each layer of the network using move semantic. More...
 
void setRandomWeights ()
 
void setErrorFunction (const error_func &error)
 Sets a new error function to minimize. This error function accepts in input the target value and the current output and returns the derivative of the error function. More...
 
std::vector< weightsMatrix > getWeights () const
 Returns a vector with the matrix of weights of each layer. More...
 
std::vector< std::size_t > getlayersSizes () const
 Returns a vector with the size of each layer. More...
 
std::vector< double > compute (const std::vector< double > &inputs)
 Computes the result for the given inputs. More...
 
void train (const sann::dataSet &trainingSet, sann::Estimator &est, const sann::parameters &hyperPar)
 Trains the network using the training set passed as input. More...
 
void train (const sann::dataSet &trainingSet, const sann::dataSet &testSet, sann::Estimator &trainEst, sann::Estimator &testEst, const sann::parameters &hyperPar)
 Trains the network using the training set passed as input. More...
 

Static Public Attributes

static sann::EstimatornullEstimator = realNullEstimator
 

Detailed Description

This is the core class, that represents the whole Neural Network.

Constructor & Destructor Documentation

◆ Network()

sann::Network::Network ( const Network net)

Creates a new network equal to an existent one.

Parameters
net- The network to copy.

Member Function Documentation

◆ compute()

vector< double > sann::Network::compute ( const std::vector< double > &  inputs)

Computes the result for the given inputs.

Parameters
inputs- The inputs of the network.
Returns
std::vector<double> - The outputs computed by the network.

◆ getlayersSizes()

vector< size_t > sann::Network::getlayersSizes ( ) const

Returns a vector with the size of each layer.

Returns
vector<size_t> - A vector with the size of each layer.

◆ getWeights()

vector< weightsMatrix > sann::Network::getWeights ( ) const

Returns a vector with the matrix of weights of each layer.

Returns
vector<weightsMatrix> - The vector with the weights matrix.

◆ setErrorFunction()

void sann::Network::setErrorFunction ( const error_func &  error)

Sets a new error function to minimize. This error function accepts in input the target value and the current output and returns the derivative of the error function.

Parameters
error- The error function to minimize.

◆ setWeights()

void sann::Network::setWeights ( std::vector< weightsMatrix > &&  weights)

Sets the weights for each layer of the network using move semantic.

Parameters
weights- The weights to set.

◆ train() [1/2]

void sann::Network::train ( const sann::dataSet trainingSet,
sann::Estimator est,
const sann::parameters hyperPar 
)

Trains the network using the training set passed as input.

Parameters
trainingSet- The training set.
est- The Estimator of the training set.
hyperPar- The hyperparameters.

◆ train() [2/2]

void sann::Network::train ( const sann::dataSet trainingSet,
const sann::dataSet testSet,
sann::Estimator trainEst,
sann::Estimator testEst,
const sann::parameters hyperPar 
)

Trains the network using the training set passed as input.

Parameters
trainingSet- The training set.
testSet- The test set.
trainEst- The Estimator for the training set.
testEst- The Estimator for the test set.
hyperPar- The hyperparameters.

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