⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 neuron.h

📁 一个简单灵活的数据挖掘实验平台
💻 H
字号:
#ifndef _NEURON_H_
#define _NEURON_H_
#include <vector>
using namespace std;
class Neuron;
class Synapse;
class Layer;

class Neuron  
{
	friend Layer;
public:	
enum _Aft
{
	sigmoid,
	linear,
};
public:
	Neuron(int aft);
    ~Neuron();
public:
	inline int    type() const;
	inline double activity() const;
	inline vector<Synapse*> in() const;
	inline vector<Synapse*> out() const;

	double activate();
private:
	int   _aft;            //: active function type
	double _activity;       //: activity of the neuron
	vector<Synapse*> _in;   //: input synapse 
	vector<Synapse*> _out;  //: output synapse
};
class Synapse
{
public:
	Synapse(Neuron* forward,Neuron* backward);
	~Synapse();
	double weight() const;
	Neuron* forward() const;
	Neuron* backward() const;
private:
	double _w;    //: weight of the synapse
	double _dw;   //: delta weight of the synapse
	Neuron* _forward;  //: forward neuron
	Neuron* _backward; //: backward neuron
	
public:
	static double random(double range = 0.05);
	static double random_range; //:gets and sets the random range
};
class Layer
{
public:	
enum _Aft
{
	sigmoid,
	linear,
};
public:	
	Layer(int aft);
	Layer(int size,int aft);
	void add(Neuron* neuron);
	Neuron* remove(int index);
	void set_activity(double* values);
public:
	//: link 2 layers together
	static void link(Layer* l1,Layer* l2);
public:
	inline int type() const;
	inline vector<Neuron*> neuron_group() const;
private:
	vector<Neuron*> _neuron_group; //: all the neurons of a layer
	int _aft;                      //: all the neurons in a layer belongs to a single type
};

#endif 

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -