mirror of
https://github.com/BlackLight/neuralpp.git
synced 2025-07-26 23:28:54 +02:00
Hey it's becoming damn cool...
This commit is contained in:
parent
adfa58800f
commit
5cb0faef82
10 changed files with 116 additions and 88 deletions
include
|
@ -41,6 +41,7 @@ namespace neuralpp {
|
|||
class NeuralNet;
|
||||
|
||||
double df (double (*f)(double), double x);
|
||||
double __actv(double prop);
|
||||
|
||||
/**
|
||||
* @class NeuralNet
|
||||
|
@ -50,6 +51,7 @@ namespace neuralpp {
|
|||
int epochs;
|
||||
int ref_epochs;
|
||||
double l_rate;
|
||||
double threshold;
|
||||
std::vector<double> expect;
|
||||
|
||||
/**
|
||||
|
@ -102,8 +104,11 @@ namespace neuralpp {
|
|||
* keep its value quite low to be more accurate)
|
||||
* @param e Epochs (cycles) to execute (the most you execute, the most the network
|
||||
* can be accurate for its purpose)
|
||||
* @param th Threshold, value in [0,1] that establishes how much a neuron must be
|
||||
* 'sensitive' on variations of the input values
|
||||
* @param a Activation function to use (default: f(x)=x)
|
||||
*/
|
||||
NeuralNet (size_t in_size, size_t hidden_size, size_t out_size, double l, int e);
|
||||
NeuralNet (size_t in_size, size_t hidden_size, size_t out_size, double l, int e, double th = 0.0, double (*a)(double) = __actv);
|
||||
|
||||
/**
|
||||
* @brief Constructor
|
||||
|
@ -123,9 +128,11 @@ namespace neuralpp {
|
|||
* keep its value quite low to be more accurate)
|
||||
* @param e Epochs (cycles) to execute (the most you execute, the most the network
|
||||
* can be accurate for its purpose)
|
||||
* @param th Threshold, value in [0,1] that establishes how much a neuron must be
|
||||
* 'sensitive' on variations of the input values
|
||||
*/
|
||||
NeuralNet (size_t in_size, size_t hidden_size, size_t out_size,
|
||||
double(*actv)(double), double l, int e);
|
||||
//NeuralNet (size_t in_size, size_t hidden_size, size_t out_size,
|
||||
// double(*actv)(double), double l, int e, double th);
|
||||
|
||||
/**
|
||||
* @brief It gets the output of the network (note: the layer output should contain
|
||||
|
@ -134,6 +141,12 @@ namespace neuralpp {
|
|||
*/
|
||||
double getOutput() const;
|
||||
|
||||
/**
|
||||
* @brief Get the threshold of the neurons in the network
|
||||
* @return The threshold of the neurons
|
||||
*/
|
||||
double getThreshold() const;
|
||||
|
||||
/**
|
||||
* @brief It gets the output of the network in case the output layer contains more neurons
|
||||
* @return A vector containing the output values of the network
|
||||
|
@ -234,7 +247,7 @@ namespace neuralpp {
|
|||
* @param set String containing input values and expected outputs
|
||||
* @return XML string
|
||||
*/
|
||||
static std::string XMLFromSet (int id, std::string set);
|
||||
static std::string XMLFromSet (int& id, std::string set);
|
||||
|
||||
/**
|
||||
* @brief Closes an open XML document generated by "initXML" and "XMLFromSet"
|
||||
|
@ -348,6 +361,7 @@ namespace neuralpp {
|
|||
class Neuron {
|
||||
double actv_val;
|
||||
double prop_val;
|
||||
double threshold;
|
||||
|
||||
std::vector< Synapsis > in;
|
||||
std::vector< Synapsis > out;
|
||||
|
@ -358,17 +372,21 @@ namespace neuralpp {
|
|||
/**
|
||||
* @brief Constructor
|
||||
* @param a Activation function
|
||||
* @param th Threshold, value in [0,1] that establishes how much a neuron must be
|
||||
* 'sensitive' on variations of the input values
|
||||
*/
|
||||
Neuron (double (*a)(double));
|
||||
Neuron (double (*a)(double), double th = 0.0);
|
||||
|
||||
/**
|
||||
* @brief Alternative constructor, that gets also the synapsis linked to the neuron
|
||||
* @param in Input synapses
|
||||
* @param out Output synapses
|
||||
* @param a Activation function
|
||||
* @param th Threshold, value in [0,1] that establishes how much a neuron must be
|
||||
* 'sensitive' on variations of the input values
|
||||
*/
|
||||
Neuron (std::vector<Synapsis> in, std::vector<Synapsis> out,
|
||||
double (*a)(double));
|
||||
double (*a)(double), double th = 0.0);
|
||||
|
||||
/**
|
||||
* @brief Get the i-th synapsis connected on the input of the neuron
|
||||
|
@ -450,6 +468,7 @@ namespace neuralpp {
|
|||
*/
|
||||
class Layer {
|
||||
std::vector<Neuron> elements;
|
||||
double threshold;
|
||||
|
||||
void (*update_weights)();
|
||||
double (*actv_f)(double);
|
||||
|
@ -459,16 +478,20 @@ namespace neuralpp {
|
|||
* @brief Constructor
|
||||
* @param sz Size of the layer
|
||||
* @param a Activation function
|
||||
* @param th Threshold, value in [0,1] that establishes how much a neuron must be
|
||||
* 'sensitive' on variations of the input values
|
||||
*/
|
||||
Layer (size_t sz, double (*a)(double));
|
||||
Layer (size_t sz, double (*a)(double), double th = 0.0);
|
||||
|
||||
/**
|
||||
* @brief Alternative constructor. It directly gets a vector of neurons to build
|
||||
* the layer
|
||||
* @param neurons Vector of neurons to be included in the layer
|
||||
* @param a Activation function
|
||||
* @param th Threshold, value in [0,1] that establishes how much a neuron must be
|
||||
* 'sensitive' on variations of the input values
|
||||
*/
|
||||
Layer (std::vector<Neuron>& neurons, double(*a)(double));
|
||||
Layer (std::vector<Neuron>& neurons, double(*a)(double), double th = 0.0);
|
||||
|
||||
/**
|
||||
* @brief Redefinition for operator []. It gets the neuron at <i>i</i>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue