亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? cpnet.cpp

?? 神經網絡:用感知規則進行感知。。來自網上的代碼
?? CPP
?? 第 1 頁 / 共 2 頁
字號:
/*
	Program Name: Perceptron
	@author: Gonzales Cenelia
	homepage: www.ai-search.4t.com

	This program features a complete Perceptron Neural Net Application.
	
	The perceptron is a program that learn concepts, i.e. it can learn to respond 
	with True (1) or False (0) for inputs we present to it, by repeatedly "studying" 
	examples presented to it. The Perceptron is a single layer neural network 
	whose weights and biases could be trained to produce a correct target vector when 
	presented with the corresponding input vector. 
	The training technique used is called the perceptron learning rule. 
	The perceptron generated great interest due to its ability to generalize 
	from its training vectors and work with randomly distributed connections. 
	Perceptrons are especially suited for simple problems in pattern classification.

    This code is copyrighted and has limited warranty.
*/
#include "cpnet.h"
#define WAIT(x) Sleep((long)(x));
#define CLEAR_SCREEN() system("cls");
#define abs(x) ((x) > 0 ? (x) : (-(x)))
#define MIN_ACCURACY 0.01
#define SECOND 1000

enum {DEFAULT, ANIM_T1, ANIM_T2, ANIM_T3, UNKNOWN} eAnimType;



CPnet::CPnet() {
	threshold = 0;
	Weight = 0;
	Target = 0;
	Output = 0;
	Input = 0;
	input = 0;
	delta = 0;
	bNeuralNetCreated = false;
	bNeuralNetTrained = false;
	bNeuralNetSaved = false;
	bNeuralNetLoaded = false;
	bNewModifications = false;
	szNeuralNetName = new char[MAX_PATH];
}

CPnet::~CPnet() {
	delete Weight;
	delete Input;
	delete Output;
	delete input;
	delete delta;
	delete Target;
	delete szNeuralNetName;
}

void CPnet::CPMenu(void) {
	int selection;
	while(selection != 8) {
		cout << "=================================================================\n";
		cout << "\tPerceptron Neural Net using Perceptron learning rule\n";
		cout << "=================================================================\n\n";
		cout << "[1]. Create a new Neural Net" << endl;
		cout << "[2]. Train the current Neural Net" << endl;
		cout << "[3]. Load a Neural Net from file" << endl;
		cout << "[4]. Test Neural Net" << endl;
		cout << "[5]. Save the current Net" << endl;
		cout << "[6]. Set training display" << endl;
		cout << "[7]. Display Neural Net Info" << endl;
		cout << "[8]. Quit the program" << endl  << endl;
		cout << "selection: ";
		selection = getche() - '0';
		WAIT(0.5*SECOND);
		CLEAR_SCREEN();
		switch(selection) {
		case 1:
			SaveCurrentData();
			cout << "\nCreating Neural Net...";
			WAIT(1*SECOND);
			CreateNet();
			break;
		case 2:
			if (bNeuralNetCreated) {
				cout << "\nTraining \"" << szNeuralNetName << "\" function..." << endl;
				WAIT(0.7*SECOND);
				cout << "Enter Learning rate: ";
				cin >> LEARNING_RATE;
				WAIT(0.7*SECOND);
				cout << "Enter number of epochs: ";
				cin >> CPN_ITER;
				NormalizeInput();
				NormalizeTarget();
				CLEAR_SCREEN();
				WAIT(0.7*SECOND);
				cout << "\nTraining \"" << szNeuralNetName << "\" function..." << endl;
				WAIT(2*SECOND);
				CLEAR_SCREEN();
				TrainNetwork();
			} else {
				UpdateScreen();
			}
			break;
		case 3:
			SaveCurrentData();
			cout << "\n\nLoading Neural Net..." << endl;
			WAIT(0.85*SECOND);
			cout << "\nEnter the name of the Neural Net or the complete path where "
			     << "the Net data can be found\n: ";
			cin.sync();
			cin.getline(szNeuralNetName, MAX_PATH);
			LoadNet();
			WAIT(1.5*SECOND);
			CLEAR_SCREEN();
			cout << "\n\n\n\n\n\n\n\n\n\t\t\tNeural Net loaded successfuly!" << endl;
			UpdateScreen();
			break;
		case 4:
			if (bNeuralNetTrained) {
				cout << "\nTesting \"" << szNeuralNetName << "\" function..." << endl;
				cout << "1. default test" << endl;
				cout << "2. selective test" << endl;
				cout << "\nselection: ";
				int nNumOfPattern;
				int sel = getche();
				CLEAR_SCREEN();
				WAIT(0.7*SECOND);
				DeNormalizeInput();
				DeNormalizeTarget();
				switch(sel) {
				case '1':
					TestNetwork();
					break;
				case '2':
					cout << "\nEnter the number of patterns to be tested: ";
					cin >> nNumOfPattern;
					SelectiveTest(nNumOfPattern);
					UpdateScreen();
					break;
				default:
					cout << "\nunknown selection." << endl;
					UpdateScreen();
				}
			} else {
				UpdateScreen();
			}
			break;
		case 5:
			if (bNeuralNetCreated) {
				if (fExist(szNeuralNetName)) {
					CLEAR_SCREEN();
					WAIT(0.5*SECOND);
					cout << "\n\"" << szNeuralNetName << "\"";
					cout << ": this file already exist,do you want to overwrite it?" << endl;
					cout << "Yes(y) No(n): ";
					char response;
					cin >> response;
					response = tolower(response);
					if(response == 'y') {
						SaveNet();
					} else {
						WAIT(0.5*SECOND);
						cout << "\nPlease enter a new name or a complete file path where the " 
							<< "Neural Net will be saved\n: ";
						cin.sync();
						cin.getline(szNeuralNetName, MAX_PATH);
						SaveNet();
					}
				} else {
					SaveNet();
				}
				CLEAR_SCREEN();
				WAIT(1.5*SECOND);
				cout << "\n\n\n\n\n\n\n\n\n\t\t\tThe Neural Net was saved successfuly!" << endl;
			}
			UpdateScreen();
			break;
		case 6:
			cout << "\n1. No animation" << endl;
			cout << "2. Animation type1" << endl;
			cout << "3. Animation type2" << endl;
			cout << "4. Animation type3" << endl;
			cout << "\nselection: ";
			char response;
			response = getche();
			switch(response) {
			case '1':
				eAnimType = DEFAULT;
				break;
			case '2':
				eAnimType = ANIM_T1;
				break;
			case '3':
				eAnimType = ANIM_T2;
				break;
			case '4':
				eAnimType = ANIM_T3;
				break;
			default:
				eAnimType = UNKNOWN;
				WAIT(0.7*SECOND);
				cout << "\nunknown selection." << endl;
			}
			if(eAnimType != UNKNOWN) {
				WAIT(0.7*SECOND);
				cout << "\nAnimation type set successfully!" << endl;
			} else {
				eAnimType = DEFAULT;
			}
			UpdateScreen();
			break;
		case 7:
			if (bNeuralNetCreated) {
				cout << "\nNeural Net Description..." << endl;
				WAIT(0.7*SECOND);
				cout << "Neural Net type: Perceptron" << endl;
				WAIT(0.5*SECOND);
				cout << "Number of Layers: 1" << endl;
				WAIT(0.5*SECOND);
				cout << "Neural Net Name: " << szNeuralNetName << endl;
				WAIT(0.5*SECOND);
				cout << "Number of Inputs per Neuron: " << input_num << endl;
				WAIT(0.5*SECOND);
				cout << "Number of Neurons: " << neuron_num << endl;
				WAIT(0.5*SECOND);
				cout << "Number of Targets: " << target_num << endl;
				WAIT(0.5*SECOND);
				cout << "Total Number of Inputs: " << total_input_num << endl;
				WAIT(1.4*SECOND);
				cout << "\nDisplaying inputs..." << endl;
				for(int i = 0; i < total_input_num; ++i) {
					WAIT(0.3*SECOND);
					cout << "Input[" << i << "] = " << Input[i] << endl;
				}
				WAIT(1.4*SECOND);
				cout << "\nDisplaying targets..." << endl;
				for(i = 0; i < target_num; ++i) {
					WAIT(0.3*SECOND);
					cout << "Target[" << i << "] = " << Target[i] << endl;
				}
			}
			UpdateScreen();
			break;
		case 8:
			SaveCurrentData();
			cout << "\n\n\n\n\nauthor: Gonzales Cenelia" << endl;
			cout << "homepage: www.ai-search.4t.com" << endl;
			cout << "Thanks for using this program!" << endl;
			break;
		default:
			cout << "\ninvalid selection." << endl;
			UpdateScreen();
		}
	}
}

// Creates a new Neural Net
void CPnet::CreateNet(void) {
	cout << "\n\nPlease enter a name for the Neural Net: ";
	cin.sync();
	cin.getline(szNeuralNetName, 30);
	WAIT(0.8*SECOND);
	cout << "Enter the number of inputs per Neuron: ";
	cin >> input_num;
	WAIT(0.8*SECOND);
	cout << "Enter the number of neurons: ";
	cin >> neuron_num;
	WAIT(0.8*SECOND);
	cout << "Enter threshold: ";
	cin >> threshold;
	cout << endl;
	target_num = neuron_num;
	total_input_num = input_num * neuron_num;
	bNeuralNetCreated = false;
	bNeuralNetTrained = false;
	bNeuralNetSaved = false;
	// allocating memory for the inputs
	Input = new float[total_input_num];
	if(!Input) {
		std::cerr << "Error while allocating memory for inputs.\n";
	}
	// allocating memory for the outputs
	Output = new float[target_num];
	if(!Output) {
		std::cerr << "Error while allocating memory for outputs.\n";
	}
	// allocating memory for temporary inputs
	input = new float[input_num];
	if(!input) {
		std::cerr << "Error while allocating memory for temporary inputs variable.\n";
	}
	// allocating memory for delta
	delta = new float[target_num];
	if(!delta) {
		std::cerr << "Error while allocating memory for delta.\n";
	}
	// allocating memory for the targets
	Target = new float[target_num];
	if(!Target) {
		std::cerr << "Error while allocating memory for targets.\n";
	}
	// allocating memory for the weights
	Weight = new float[input_num];
	if(!Weight) {
		std::cerr << "Error while allocating memory for weights.\n";
	}
	WAIT(1*SECOND);
	for(int i = 0; i < total_input_num; ++i) {
		cout << "input[" << i << "] = ";
		cin >> Input[i];
		if ( input_num > 1 && !((i + 1) % input_num)) {
			cout << endl;
		}
		WAIT(0.4*SECOND);
	}
	WAIT(1*SECOND);
	cout << endl << endl;
	for(i = 0; i < target_num; ++i) {
		cout << "target[" << i << "] = ";
		cin >> Target[i];
		WAIT(0.4*SECOND);
	}
	RandomizeWeights();
	bNeuralNetCreated = true;
	CLEAR_SCREEN();
	cout << "\nCreating Neural Net...";
	WAIT(2*SECOND);
	cout << "\n\nThe Neural Net was created successfuly!" << endl;
	WAIT(0.6*SECOND);
	cout << "\nNext step: Training\n\n";
	UpdateScreen();
}

// initialise the weights with 
// random values between -1 and 1
void CPnet::RandomizeWeights() {
	srand( ( unsigned )time( NULL ) );
	for(int i=0; i<input_num; ++i) {
		Weight[i] = (float)(rand())/(RAND_MAX/2) - 1;
	}
}

// normalize the given input vector
void CPnet::NormalizeInput() {
	Max = abs(Input[0]);
	for(int i = 0; i < total_input_num; ++i) {
		if(abs(Input[i]) > Max) {
			Max = abs(Input[i]);
		}
	}
	if(Max > 1) {
		for(i = 0; i < total_input_num; ++i) {
			Input[i] /= Max;
		}
	}
}

// denormalize input vector		
void CPnet::DeNormalizeInput() {
	if(Max > 1) {
		for(int i = 0; i < total_input_num; ++i) {
			Input[i] *= Max;
		}
	}
}

// normalize target vector
void CPnet::NormalizeTarget() {

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
日本美女视频一区二区| 久久久精品影视| 亚洲一区二区四区蜜桃| 日本高清不卡视频| 一区二区三区中文在线观看| 色美美综合视频| 五月综合激情婷婷六月色窝| 91精品国产一区二区人妖| 久久99深爱久久99精品| 久久婷婷成人综合色| 国产福利精品导航| 亚洲免费看黄网站| 欧美欧美午夜aⅴ在线观看| 日韩国产精品久久| 国产日韩亚洲欧美综合| 91理论电影在线观看| 天涯成人国产亚洲精品一区av| 欧美一区2区视频在线观看| 国产风韵犹存在线视精品| 亚洲视频一区二区免费在线观看 | 一区二区三区欧美激情| 欧美浪妇xxxx高跟鞋交| 久久99国产乱子伦精品免费| 国产精品入口麻豆九色| 欧美日韩国产首页在线观看| 国产在线精品不卡| 亚洲欧美偷拍卡通变态| 在线电影一区二区三区| 国产iv一区二区三区| 亚洲国产精品久久久久婷婷884| 日韩视频免费观看高清完整版在线观看| 国产一区美女在线| 一区二区三区欧美日| 久久夜色精品一区| 91官网在线免费观看| 国产一区二区网址| 亚洲成人午夜影院| 国产精品视频在线看| 91精品国产免费| 99久久国产综合精品色伊| 免费在线视频一区| 亚洲综合成人在线视频| 欧美国产日韩a欧美在线观看| 欧美日韩国产首页| 欧洲视频一区二区| 成人国产精品免费| 久久99九九99精品| 午夜不卡av在线| 一区二区三区视频在线看| 国产精品视频在线看| 久久伊99综合婷婷久久伊| 欧美日韩美女一区二区| 99国产精品视频免费观看| 精品一区二区免费在线观看| 日韩激情一区二区| 亚洲激情图片小说视频| 欧美激情中文不卡| 欧美大片一区二区| 日韩久久久久久| 这里只有精品电影| 91麻豆精品国产91久久久更新时间| 99re热视频精品| 成人性生交大片免费看在线播放| 蜜桃精品视频在线| 日本aⅴ免费视频一区二区三区| 亚洲制服丝袜一区| 亚洲狠狠丁香婷婷综合久久久| 国产精品国产馆在线真实露脸| 亚洲国产精品精华液2区45| 2020日本不卡一区二区视频| 精品国产伦一区二区三区免费| 日韩午夜激情视频| 日韩欧美一级精品久久| 67194成人在线观看| 欧美精品成人一区二区三区四区| 欧美三级电影一区| 欧美另类变人与禽xxxxx| 56国语精品自产拍在线观看| 91麻豆精品国产91久久久| 欧美猛男男办公室激情| 8v天堂国产在线一区二区| 欧美日韩一级黄| 在线电影院国产精品| 日韩一级片在线观看| 欧美大片在线观看一区二区| 久久久久久久久久电影| 欧美激情在线看| 最新热久久免费视频| 亚洲欧美日韩国产成人精品影院| 亚洲欧美偷拍另类a∨色屁股| 一区二区三区四区精品在线视频| 亚洲国产成人porn| 日本欧美一区二区在线观看| 久久av中文字幕片| 成人的网站免费观看| 色av综合在线| 欧美肥胖老妇做爰| 久久久久久久网| 中文字幕一区二区三区av| 亚洲一区二区三区精品在线| 视频一区免费在线观看| 国产呦萝稀缺另类资源| 99re这里只有精品视频首页| 欧美日精品一区视频| 精品久久久久一区二区国产| 国产精品免费av| 亚洲制服丝袜av| 国产真实乱子伦精品视频| 99精品在线观看视频| 正在播放亚洲一区| 国产网站一区二区| 亚洲第一在线综合网站| 国产精品一区二区不卡| 一本一本大道香蕉久在线精品| 日韩一区二区电影网| 中文字幕制服丝袜一区二区三区| 亚洲第一主播视频| 丁香婷婷综合网| 制服丝袜中文字幕一区| 国产精品短视频| 男男gaygay亚洲| 色婷婷久久久亚洲一区二区三区| 欧美一区二区三区影视| 国产精品成人免费在线| 免费人成在线不卡| 色综合久久中文综合久久97| 精品免费视频一区二区| 亚洲午夜电影网| 丁香婷婷综合激情五月色| 在线播放视频一区| 日韩毛片在线免费观看| 国产综合久久久久久鬼色 | 日韩精品一区二区三区四区| 亚洲国产精品黑人久久久| 青青草伊人久久| 91搞黄在线观看| 中文字幕日本不卡| 久久电影网电视剧免费观看| 一本大道久久精品懂色aⅴ| 久久久久国产免费免费| 奇米综合一区二区三区精品视频| 色先锋aa成人| 国产精品美女视频| 精品一区免费av| 欧美精品高清视频| 亚洲一区二区中文在线| www.欧美日韩| 欧美激情综合五月色丁香| 国产在线精品国自产拍免费| 日韩三级视频中文字幕| 亚洲成a人片综合在线| 欧美在线不卡一区| 亚洲精品一二三| 色菇凉天天综合网| 亚洲精品午夜久久久| 99久精品国产| 综合在线观看色| 粉嫩高潮美女一区二区三区| 久久精品人人爽人人爽| 精品午夜一区二区三区在线观看| 欧美一级二级在线观看| 丝袜亚洲另类欧美综合| 欧美日本高清视频在线观看| 天天射综合影视| 欧美伦理视频网站| 奇米精品一区二区三区在线观看 | 欧美在线观看一区二区| 亚洲精品乱码久久久久久日本蜜臀| www.成人网.com| 国产精品丝袜91| 色综合色狠狠天天综合色| 一区二区久久久久久| 欧美专区在线观看一区| 午夜亚洲国产au精品一区二区| 欧美亚洲动漫制服丝袜| 天天操天天色综合| 精品国产一区二区精华| 高清免费成人av| 亚洲黄色录像片| 91麻豆精品国产91久久久资源速度 | 亚洲综合自拍偷拍| 欧美精品日韩一区| 激情亚洲综合在线| 国产欧美日韩三级| 91亚洲国产成人精品一区二三| 亚洲精品久久嫩草网站秘色| 欧美日韩综合一区| 免费国产亚洲视频| 国产喂奶挤奶一区二区三区| 成人动漫一区二区在线| 一区二区三区精品视频在线| 欧美电影一区二区三区| 国产精品中文字幕欧美| 亚洲免费高清视频在线| 日韩亚洲欧美一区| 大美女一区二区三区| 亚洲最色的网站| 久久―日本道色综合久久| 99久久精品免费看国产| 婷婷久久综合九色综合绿巨人|