PHP中XOR (异或)训练,很久不看PHP,突然发现已经非常强大了,什么SVM、FANN一应俱全了,谁让AI大潮了
来源:互联网 发布:淘宝网班尼路 编辑:程序博客网 时间:2024/06/06 01:43
http://php.net/manual/zh/book.fann.php
以下例子展示了怎么训练数据来实现 XOR (异或)功能。
Example #1 xor.data file
4 2 1-1 -1-1-1 111 -111 1-1
数据解读:
Here is an explanation for the input file for training, as it might be obvious to everyone and you must understand it to write your own:4 2 1 <- header file saying there are 4 sets to read, with 2 inputs and 1 output-1 -1 <- the 2 inputs for the 1st group-1 <- the 1 output for the 1st group-1 1 <- the 2 inputs for the 2nd group1 <- the 1 output for the 2nd group1 -1 <- the 2 inputs for the 3rd group1 <- the 1 output for the 3rd group1 1 <- the 2 inputs for the 4th group-1 <- the 1 output for the 4th group
Example #2 一般训练
<?php$num_input = 2;$num_output = 1;$num_layers = 3;$num_neurons_hidden = 3;$desired_error = 0.001;$max_epochs = 500000;$epochs_between_reports = 1000;$ann = fann_create_standard($num_layers, $num_input, $num_neurons_hidden, $num_output);if ($ann) { fann_set_activation_function_hidden($ann, FANN_SIGMOID_SYMMETRIC); fann_set_activation_function_output($ann, FANN_SIGMOID_SYMMETRIC); $filename = dirname(__FILE__) . "/xor.data"; if (fann_train_on_file($ann, $filename, $max_epochs, $epochs_between_reports, $desired_error)) fann_save($ann, dirname(__FILE__) . "/xor_float.net"); fann_destroy($ann);}?>
这个例子展示怎么读取神经网络并且使用 XOR (异或)功能来运行数据。
Example #3 一般测试
<?php$train_file = (dirname(__FILE__) . "/xor_float.net");if (!is_file($train_file)) die("The file xor_float.net has not been created! Please run simple_train.php to generate it");$ann = fann_create_from_file($train_file);if (!$ann) die("ANN could not be created");$input = array(-1, 1);$calc_out = fann_run($ann, $input);printf("xor test (%f,%f) -> %f\n", $input[0], $input[1], $calc_out[0]);fann_destroy($ann);?>
A helpful reference for FANN is available here:
http://leenissen.dk/fann/html/files2/theory-txt.html
阅读全文
0 0
- PHP中XOR (异或)训练,很久不看PHP,突然发现已经非常强大了,什么SVM、FANN一应俱全了,谁让AI大潮了
- php 很久没写了
- 今天突然发现CSDN中博客改了,自己已经几天没完成任务了
- 移动互联网大潮中,百度已经落后了
- 突然就接触了php
- 很久都没写点什么了
- 突然发现,已经好久没更新blog了...
- 已经很久很久不写文章了
- 突然想说点什么了
- 突然发现好久不写博文了
- AI大潮之下,“造物主”码农也要失业了?【智库2861】
- 已经很久没有写代码了
- 突然明白了点什么
- 旧闻 , PHP已经拿起了切刀!
- 很久没有看c了,突然忘记c中的真假代表什么了,在vc++6.0测试一下
- 很久,很久了
- 分享一个用了很久的php日志类
- php过时了还是已经没人用了?
- Android 截屏方法
- 数据库第四课
- IT项目经理与职能经理的工作有什么不同
- Win10配置Java环境,解决javac不是内部或外部命令的问题
- 华清远见系统移植考试复习题
- PHP中XOR (异或)训练,很久不看PHP,突然发现已经非常强大了,什么SVM、FANN一应俱全了,谁让AI大潮了
- C/C++中产生随机数(rand,srand用法)
- spring-boot之helloworld
- 基于JQuery和ES6的前端轮转抽奖
- ZF
- Android四大组件:BroadcastReceiver
- Struts开发笔记二
- 优秀的前端框架总结
- iOS 获取当前app的名称和版本号