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

📄 robot.c

📁 一个功能强大的神经网络分析程序
💻 C
字号:
/*Fast Artificial Neural Network Library (fann)Copyright (C) 2003 Steffen Nissen (lukesky@diku.dk)This library is free software; you can redistribute it and/ormodify it under the terms of the GNU Lesser General PublicLicense as published by the Free Software Foundation; eitherversion 2.1 of the License, or (at your option) any later version.This library is distributed in the hope that it will be useful,but WITHOUT ANY WARRANTY; without even the implied warranty ofMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNULesser General Public License for more details.You should have received a copy of the GNU Lesser General PublicLicense along with this library; if not, write to the Free SoftwareFoundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA*/#include <stdio.h>#include "fann.h"int print_callback(unsigned int epochs, float error){	printf("Epochs     %8d. Current MSE-Error: %.10f\n", epochs, error);	return 0;}int main(){	const float connection_rate = 1;	const float learning_rate = (const float)0.7;	const unsigned int num_layers = 3;	const unsigned int num_neurons_hidden = 96;	const float desired_error = (const float)0.001;	struct fann *ann;	struct fann_train_data *train_data, *test_data;		unsigned int i = 0;	printf("Creating network.\n");	train_data = fann_read_train_from_file("../benchmarks/datasets/robot.train");	ann = fann_create(connection_rate, learning_rate, num_layers,		train_data->num_input,		num_neurons_hidden,		train_data->num_output);	printf("Training network.\n");	fann_set_training_algorithm(ann, FANN_TRAIN_INCREMENTAL);		fann_train_on_data(ann, train_data, 1000, 10, desired_error);		/*fann_train_on_data_callback(ann, data, max_iterations, iterations_between_reports, desired_error, print_callback);*/	printf("Testing network.\n");	test_data = fann_read_train_from_file("../benchmarks/datasets/robot.test");	fann_reset_MSE(ann);	for(i = 0; i < test_data->num_data; i++){		fann_test(ann, test_data->input[i], test_data->output[i]);	}	printf("MSE error on test data: %f\n", fann_get_MSE(ann));	printf("Saving network.\n");	fann_save(ann, "robot_float.net");	printf("Cleaning up.\n");	fann_destroy_train(train_data);	fann_destroy_train(test_data);	fann_destroy(ann);		return 0;}

⌨️ 快捷键说明

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