71 lines
1.4 KiB
C++
71 lines
1.4 KiB
C++
#pragma once
|
|
|
|
#include <string>
|
|
|
|
namespace NeuralNetwork
|
|
{
|
|
/**
|
|
* @author Tomas Cernik (Tom.Cernik@gmail.com)
|
|
* @brief Abstract class of neuron. All Neuron classes should derive from this on
|
|
*/
|
|
class Neuron
|
|
{
|
|
public:
|
|
|
|
/**
|
|
* @brief returns unique id for neuron
|
|
*/
|
|
virtual unsigned long id() const =0;
|
|
|
|
/**
|
|
* @brief virtual destructor for Neuron
|
|
*/
|
|
virtual ~Neuron() {};
|
|
|
|
/**
|
|
* @brief This is a virtual function for storing network
|
|
* @returns json describing network and it's state
|
|
*/
|
|
virtual std::string stringify(const std::string &prefix="") const =0;
|
|
|
|
/**
|
|
* @brief Gets weight
|
|
* @param n is neuron
|
|
*/
|
|
virtual float getWeight(const Neuron &n) const =0;
|
|
|
|
/**
|
|
* @brief Sets weight
|
|
* @param n is neuron
|
|
* @param w is new weight for input neuron n
|
|
*/
|
|
virtual void setWeight(const Neuron& n ,const float &w) =0;
|
|
|
|
/**
|
|
* @brief Returns output of neuron
|
|
*/
|
|
virtual float output() const =0;
|
|
|
|
/**
|
|
* @brief Returns input of neuron
|
|
*/
|
|
virtual float value() const=0;
|
|
|
|
/**
|
|
* @brief Returns value for derivation of activation function
|
|
*/
|
|
// virtual float derivatedOutput() const=0;
|
|
|
|
/**
|
|
* @brief Function sets bias for neuron
|
|
* @param bias is new bias (initial value for neuron)
|
|
*/
|
|
virtual void setBias(const float &bias)=0;
|
|
|
|
/**
|
|
* @brief Function returns bias for neuron
|
|
*/
|
|
virtual float getBias() const=0;
|
|
protected:
|
|
};
|
|
} |