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

📄 chopfield.h

📁 This fiel shows how to use Hopfield networks
💻 H
字号:

#ifndef _HOPFIELD_H_
#define _HOPFIELD_H_

#include <fstream.h>
#include <time.h>
#include <stdlib.h>

#define	NUMDATA		3
#define RESX		16
#define RESY		16
#define ELEMENTS	RESX * RESY

#define _binary(x)  ((x == -1) ? false : true)
#define _bipolar(x) ((x) ? 1 : -1)

typedef int(*_callback)(int, int);

class CHopfield {
	public:
		CHopfield();
		~CHopfield();

		bool ReadData(char *);		// Read the data.
		
		void Run(int);				// Run the net.
		void Train() { TrainNet(); }// Train the net.

		void GetOutput(bool *, int);// Get the output.

		// Sets the callback function. See Generation5
		// at http://library.advanced.org/18242/hir.shtml
		void SetCallback(_callback);

	protected:
		// The inputs.
		int m_iInputs[NUMDATA][ELEMENTS];

		int	*m_piOutputs;			// The outputs.
		int *m_piThresholds;		// The thresholds.
		int **m_hiWeights;			// The weights.

		void TrainNet();			// Train the network.
		void RunNet();				// Run the network.

		void AdvanceNet();			// Advance the net.
		bool AdvanceNeuron(int);	// Advance a neuron. 

		_callback ImageAltered;		// Callback function.
};

#endif

⌨️ 快捷键说明

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