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

📄 network.h

📁 函数逼近
💻 H
字号:
/*
 * 
 *	 Copyright 2004-2006 Ghassan OREIBY
 *   
 * 	 This file is part of Neurality.
 *
 *   Neurality is free software; you can redistribute it and/or modify
 *   it under the terms of the GNU General Public License as published by
 *   the Free Software Foundation; either version 2 of the License, or
 *   (at your option) any later version.
 *
 *   Neurality is distributed in the hope that it will be useful,
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *   GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *   along with Neurality; if not, write to the Free Software
 *   Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 *
 * 
 */


#pragma once
#include "NeuralNetwork.h"


#ifndef		__NETWORK__
#define		__NETWORK__


#define		MAX_ITR 500000

#define		NN_MLP		0		// Multilayered perceptron
#define		NN_MCL		1		// Massively connected layers

CLASSEXPORT class  CLASS_DECLSPEC CNetwork
{
public:
	CNetwork(void);
	~CNetwork(void);
	CNetwork(CLayer * HiddenLayer[], const int& nHiddenSize, const int& nInSize,
			const int& nOutSize, const real& reInNormMin = .0f,	const real& reInNormMax = 1.0f,   
			const real& reOutNormMin = .0f, const real& reOutNormMax = 1.0f, const int& ntype = NN_MLP);
	CNetwork(char * FileName);	// One argument constructor that loads the network from file

	// The Hidden layer linked list
	CLayer **HiddenLayers;
	// The Input Layer
	CLayer* InputLayer;
	// The Output Layer
	CLayer* OutputLayer;
private:
	// The size of the input layers (how many nodes contains the input layer)
	int nInputSize;
	// The size of the Output Layer (how many nodes contains the output layer)
	int nOutputSize;
public:
	// Returns the size of the input layer
	int GetInputSize(void) const;
	// Returns the size of the output layer.
	int GetOutputSize(void) const;

protected:
	// Assigns the output array (or vector) with the corresponding value of the input
	bool CNetwork::ComputeOutputforThisInputStandard(const real InputArray[], real *OutputArray) const;
public:
	// Make the network learn (with backpropagation algorithm) the input/output couple
	int Learn(const int& nSamples, const real InputArray[], const real DesiredOutputArray[], 
		const real& reDesiredError, const int& nItrShow = 1000, const int& nItrSave = 100000, 
		HDC *ClientDC = NULL, RECT *rect = NULL, BOOL* pbContinue = NULL);
private:
	// The Number of Hidden layers
	int nHiddenLayers;
	// This is the Threshold node, it is connected to all nodes in the network (except the Input Layer's one)
	CNode* ThresholdNode;
public:
	// Set the threshold node value
	void SetThresholdValue(real reValue);
	// Save the current Network to file with all required parameters
	bool SaveToFile(char* FileName, bool bWithLearnParams = false);
private:
	// This will be used when normalizing the input
	real reInputNormalizationMax, reInputNormalizationMin;
	// This will be used when denormalizing the output
	real reOutputNormalizationMax, reOutputNormalizationMin;
	// The type of the network (In connection point of view)
	int nType;
protected:
	// Normalize a vector of real (nInOrOut = 0 for input vector, 1 for Output vector)
	void Normalize(const real reToNormalize[], real ** reNormalized, const int &nInOrOut) const;
private:
	// The Minimum for Normalization
	real reNormMin;
	// The Maximum for Normalization
	real reNormMax;
	// The alpha on my normalization formula for Input/Output
	real reNormSlopeIn, reNormSlopeOut;
	// The Beta on my normalization formula for Input/Output
	real reNormTransIn, reNormTransOut;
	// The State of the Network (working = true, else = false)
	bool bState;
protected:
	// DeNormalize a vector of real (nInOrOut = 0 for input vector, 1 for Output vector)
	void DeNormalize(const real reToDeNormalize[], real ** reDeNormalized, const int& nInOrOut) const;
public:
	// Set the normalization parameters
	void ComputeOutput(const real reInputArray[],  real *reOutputArray) const;
	void SetNorm(const real& InNormMin, const real& InNormMax, const real& OutNormMin, const real& OutNormMax);
	bool GetState(void) const;
	// Adjust the Learning options for the Network
	static void AdjustLearning(const real& reEta, const real& reAlpha, const real& reBeta, const real& reKappa, const real& reXi);
};

#endif

⌨️ 快捷键说明

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