资源简介
c语言 神经网络算法
代码片段和文件信息
/*
Fast Artificial Neural Network Library (fann)
Copyright (C) 2003-2016 Steffen Nissen (steffen.fann@gmail.com)
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 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 of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not write to the Free Software
Foundation Inc. 59 Temple Place Suite 330 Boston MA 02111-1307 USA
*/
#include
#include “fann.h“
int main()
{
struct fann *ann;
struct fann_train_data *train_data *test_data;
const float desired_error = (const float)0.0;
unsigned int max_neurons = 30;
unsigned int neurons_between_reports = 1;
unsigned int bit_fail_train bit_fail_test;
float mse_train mse_test;
unsigned int i = 0;
fann_type *output;
fann_type steepness;
int multi = 0;
enum fann_activationfunc_enum activation;
enum fann_train_enum training_algorithm = FANN_TRAIN_RPROP;
printf(“Reading data.\n“);
train_data = fann_read_train_from_file(“../../datasets/parity8.train“);
test_data = fann_read_train_from_file(“../../datasets/parity8.test“);
fann_scale_train_data(train_data -1 1);
fann_scale_train_data(test_data -1 1);
printf(“Creating network.\n“);
ann = fann_create_shortcut(2 fann_num_input_train_data(train_data) fann_num_output_train_data(train_data));
fann_set_training_algorithm(ann training_algorithm);
fann_set_activation_function_hidden(ann FANN_SIGMOID_SYMMETRIC);
fann_set_activation_function_output(ann FANN_LINEAR);
fann_set_train_error_function(ann FANN_ERRORFUNC_LINEAR);
if(!multi)
{
/*steepness = 0.5;*/
steepness = 1;
fann_set_cascade_activation_steepnesses(ann &steepness 1);
/*activation = FANN_SIN_SYMMETRIC;*/
activation = FANN_SIGMOID_SYMMETRIC;
fann_set_cascade_activation_functions(ann &activation 1);
fann_set_cascade_num_candidate_groups(ann 8);
}
if(training_algorithm == FANN_TRAIN_QUICKPROP)
{
fann_set_learning_rate(ann 0.35f);
fann_randomize_weights(ann -2.0f 2.0f);
}
fann_set_bit_fail_limit(ann (fann_type)0.9);
fann_set_train_stop_function(ann FANN_STOPFUNC_BIT);
fann_print_parameters(ann);
fann_save(ann “cascade_train2.net“);
printf(“Training network.\n“);
fann_cascadetrain_on_data(ann train_data max_neurons neurons_between_reports desired_error);
fann_print_connections(ann);
mse_train = fann_test_data(ann train_data);
bit_fail_train = fann_get_bit_fail(ann);
mse_test = fann_test_data(ann test_data);
bit_fail_test = fann_get_bit_fail(ann);
printf(“\nTrain error: %f
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
目录 0 2015-11-29 13:53 fann-master\
文件 587 2015-11-29 13:53 fann-master\.gitignore
目录 0 2015-11-29 13:53 fann-master\.idea\
文件 159 2015-11-29 13:53 fann-master\.idea\encodings.xm
文件 70683 2015-11-29 13:53 fann-master\.idea\fann.iml
文件 137 2015-11-29 13:53 fann-master\.idea\misc.xm
文件 260 2015-11-29 13:53 fann-master\.idea\modules.xm
目录 0 2015-11-29 13:53 fann-master\.idea\runConfigurations\
文件 413 2015-11-29 13:53 fann-master\.idea\runConfigurations\Tests.xm
文件 180 2015-11-29 13:53 fann-master\.idea\vcs.xm
文件 417 2015-11-29 13:53 fann-master\.travis.yml
文件 4926 2015-11-29 13:53 fann-master\CMakeLists.txt
文件 26934 2015-11-29 13:53 fann-master\LICENSE.md
文件 2864 2015-11-29 13:53 fann-master\README.md
目录 0 2015-11-29 13:53 fann-master\VS2010\
目录 0 2015-11-29 13:53 fann-master\VS2010\cascade_train\
文件 7876 2015-11-29 13:53 fann-master\VS2010\cascade_train\cascade_train.vcxproj
文件 229 2015-11-29 13:53 fann-master\VS2010\cascade_train\cascade_train.vcxproj.filters
文件 13474 2015-11-29 13:53 fann-master\VS2010\fann.sln
文件 4243 2015-11-29 13:53 fann-master\VS2010\fann_tests.sln
目录 0 2015-11-29 13:53 fann-master\VS2010\fanndouble\
文件 9834 2015-11-29 13:53 fann-master\VS2010\fanndouble\fanndouble.vcxproj
文件 2880 2015-11-29 13:53 fann-master\VS2010\fanndouble\fanndouble.vcxproj.filters
目录 0 2015-11-29 13:53 fann-master\VS2010\fannfixed\
文件 2436 2015-11-29 13:53 fann-master\VS2010\fannfixed\fannfixed.filters
文件 9357 2015-11-29 13:53 fann-master\VS2010\fannfixed\fannfixed.vcxproj
目录 0 2015-11-29 13:53 fann-master\VS2010\fannfloat\
文件 9461 2015-11-29 13:53 fann-master\VS2010\fannfloat\fannfloat.vcxproj
文件 2769 2015-11-29 13:53 fann-master\VS2010\fannfloat\fannfloat.vcxproj.filters
目录 0 2015-11-29 13:53 fann-master\VS2010\gtest\
文件 8331 2015-11-29 13:53 fann-master\VS2010\gtest\gtest.vcxproj
............此处省略617个文件信息
- 上一篇:基于UDP的通信程序设计
- 下一篇:热血江湖服务端C++源代码,完整游戏服务器代码
相关资源
- 郝斌C语言详细笔记 附源码91146
- MFC+Access图书馆管理系统
- 谭浩强《C语言程序设计》考研考点讲
- 小甲鱼C语言课件
- C语言多关卡可视化推箱子
- 基于MSP430的DAC7811控制-C语言
- C语言链表应用的完整版ATM提款机
- 《单片机C语言程序设计实训100例——
- 西安电子科技大学软件工程C语言程序
- C语言点滴 赵岩著 pdf
- C语言邻接表结构实现克鲁斯卡尔算法
- C语言教程第五版
- 基于51单片机的正弦波发生器.rar
- 郝斌C语言源代码
- mcp4531 数字电位器c语言驱动和电路
- 用C语言写的串口调试精灵
- 《c程序设计试题汇编》谭浩强 电子版
- 数据结构(c语言版 严蔚敏著
- C语言读取BMP图像,并进行反色操作
- c语言程序设计pdf——谭浩强.pdf
- 有限元三角形与悬臂梁
- 谭浩强C程序设计第三版课件
- 基于C语言的数字图像处理
- 新手C语言MP3播放器
- C语言搭建的简单web服务器
- C语言课程设计 猜数字游戏 文档
- C语言课程设计 猜数字游戏
- 职工工资管理系统C语言
- 学生选课系统课程设计报告及代码
- 105个C语言编程代码
评论
共有 条评论