neuron.h

#ifndef __SHAREWIZ_NEURON_H__
#define __SHAREWIZ_NEURON_H__
 
#include <memory>
#include <vector>
 
#include "activation.h"
 
// Neuron class.
//
// Represents Synapsis within the brain.
 
 
class Connection;
 
typedef std::shared_ptr<Connection> pConnectionX;
typedef std::vector<pConnectionX> pConnection;
 
 
class Neuron
{
private:
	int index;
	double value;
	double gradient;  // How far off, and in what direction (positive or negative), local value are relative to the target outputs.
 
	pConnection connections_in;
	pConnection connections_out;
 
  pActivationX activation;
 
public:
	Neuron();
 
	bool operator==(Neuron& rhs) const;
 
	unsigned int getSizeIn(void);  // Returns how many connections.
	unsigned int getSizeOut(void);  // Returns how many connections.
 
	void addConnectionIn(const pConnectionX& c);
	void addConnectionOut(const pConnectionX& c);
 
	pConnectionX &getConnectionIn(const unsigned int& idx);
	pConnectionX &getConnectionOut(const unsigned int& idx);
 
	void pruneConnectionIn(const double& threshold);  // Remove all synapses with a value below the indicated threshold.
	void pruneConnectionOut(const double& threshold);  // Remove all synapses with a value below the indicated threshold.
 
  void removeConnectionIn(const unsigned int& idx);
  void removeConnectionOut(const unsigned int& idx);
 
  double getGradient(void);
	void setGradient(const double& gradient);
 
	int getIndex(void);
	void setIndex(const int& index);
 
	double getValue(void);
	void setValue(const double& v);
 
	double randomizeValue(void);
 
  pActivationX &getActivation(void);
  Activation_Types getActivationType();
  void setActivationType(Activation_Types _activation_type);
 
	double sigmoid(const double& weightedSum);
	double sigmoid_derivative(const double& x);
	double sigmoidX(double x);
 
	double hyperTanFunction(double& x);
	double tanh_derivative(const double& x);
 
	void printOutput(void);
};
 
 
#endif