新版Matlab中神经网络训练函数Newff的使用方法

一、

介绍新版newff

Syntax

·

net =

newff(P,T,[S1 S2...S(N-l)],{TF1 TF2...TFNl},

BTF,BLF,PF,IPF,OPF,DDF)

Description

newff(P,T,[S1 S2...S(N-l)],{TF1 TF2...TFNl},

BTF,BLF,PF,IPF,OPF,DDF) takes several arguments

P

R x Q1 matrix of Q1 sample R-element input

vectors

T

SN x Q2 matrix of Q2 sample SN-element

target vectors

Si

Size of ith layer, for N-1 layers, default

= [ ].

(Output layer size SN is determined from T.)

TFi

Transfer function of ith layer. (Default =

'tansig' for

hidden layers and 'purelin' for output layer.)

BTF

Backpropagation network training function

(default = 'trainlm')

BLF

Backpropagation weight/bias learning

function (default = 'learngdm')

IPF

Row cell array of input processing

functions. (Default =

{'fixunknowns','removeconstantrows','mapminmax'})

OPF

Row cell array of output processing

functions. (Default =

{'removeconstantrows','mapminmax'})

DDF

Data divison function (default =

'dividerand')

Examples

Here is a

problem consisting of inputs P and targets T to be solved with a

network.

·

P = [0 1 2 3 4 5

6 7 8 9 10];T = [0 1 2 3 4 3 2 1 2 3 4];

Here a network is created

with one hidden layer of five neurons.

·

net =

newff(P,T,5);

The network is simulated and

its output plotted against the targets.

·

Y =

sim(net,P);plot(P,T,P,Y,'o')

The network is trained for

50 epochs. Again the network's output is plotted.

·

net.trainParam.epochs = 50;net = train(net,P,T);Y =

sim(net,P);plot(P,T,P,Y,'o')

二、

新版newff与旧版newff调用语法对比

Example1

比如输入input(6*1000),输出output为(4*1000),那么

旧版定义:net=newff(minmax(input),[14,4],{'tansig','purelin'},'trainlm');

新版定义:net=newff(input,output,14,{'tansig','purelin'},'trainlm');

Example2

比如输入input(6*1000),输出output为(4*1000),那么

旧版定义:net=newff(minmax(input),[49,14,4],{'tansig','tansig','tansig'},'traingdx');

新版定义:net=newff(input,output, [49,14],

{'tansig','tansig','tansig'},'traingdx');

三、

旧版newff使用方法在新版本中使用

提示:旧版本定义的newff虽也能在新版本中使用,但会有警告,警告如下:

Warning: NEWFF used in an obsolete way.

> In obs_use at 18

In newff>create_network at

127

In newff at 102

See help

for NEWFF to update calls to the new argument

list.

四、

新版newff与旧版newff使用的训练效果对比

旧版本:旧用法训练次数多,但精度高

新版本:新用法训练次数少,但精度可能达不到要求

造成上述原因是:

程序里面的权值、阈值的初始值是随机赋值的,所以每次运行的结果都会不一样,有好有坏。你可以把预测效果不错的网络的权值和阈值作为初始值。具体可以查看net.iw{1,1}、net.lw{2,1}、net.b{1}、net.b{2}的值。

现在给一个完整的例子

%% 清空环境变量

clc

clear

%% 训练数据预测数据

data=importdata('test.txt');

%从1到768间随机排序

k=rand(1,768);

[m,n]=sort(k);

%输入输出数据

input=data(:,1:8);

output

=data(:,9);

%随机提取500个样本为训练样本,268个样本为预测样本

input_train=input(n(1:500),:)';

output_train=output(n(1:500),:)';

input_test=input(n(501:768),:)';

output_test=output(n(501:768),:)';

%输入数据归一化

[inputn,inputps]=mapminmax(input_train);

%% BP网络训练

% %初始化网络结构

net=newff(inputn,output_train,10);

net.trainParam.epochs=1000;

net.trainParam.lr=0.1;

net.trainParam.goal=0.0000004;

%% 网络训练

net=train(net,inputn,output_train);

%% BP网络预测

%预测数据归一化

inputn_test=mapminmax('apply',input_test,inputps);

%网络预测输出

BPoutput=sim(net,inputn_test);

%% 结果分析

%根据网络输出找出数据属于哪类

BPoutput(find(BPoutput<0.5))=0;

BPoutput(find(BPoutput>=0.5))=1;

%% 结果分析

%画出预测种类和实际种类的分类图

figure(1)

plot(BPoutput,'og')

hold

on

plot(output_test,'r*');

legend('预测类别','输出类别')

title('BP网络预测分类与实际类别比对','fontsize',12)

ylabel('类别标签','fontsize',12)

xlabel('样本数目','fontsize',12)

ylim([-0.5

1.5])

%预测正确率

rightnumber=0;

for

i=1:size(output_test,2)

if BPoutput(i)==output_test(i)

rightnumber=rightnumber+1;

end

end

rightratio=rightnumber/size(output_test,2)*100;

sprintf('测试准确率=%0.2f',rightratio)

新版matlab newff,[转载]新版Matlab中神经网络训练函数Newff的使用方法相关推荐

  1. matlab里newff,新版matlab中神经网络训练函数newff的使用方法

    新版matlab中神经网络训练函数newff的使用方法 新版 Matlab 中神经网络训练函数 Newff 的使用方法一. 介绍新版 newffSyntax net = newff(P,T,[S1 ...

  2. matlab newff,新版Matlab中神经网络训练函数Newff的使用方法.doc

    新版Matlab中神经网络训练函数Newff的使用方法 介绍新版newff Syntax net = newff(P,T,[S1 S2...S(N-l)],{TF1 TF2...TFNl}, BTF, ...

  3. Matlab newff 训练时间,新版Matlab中神经网络训练函数Newff的使用方法

    新版Matlab中神经网络训练函数Newff的使用方法 一. 介绍新版newff Syntax · net = newff(P,T,[S1 S2...S(N-l)],{TF1 TF2...TFNl}, ...

  4. 新版Matlab中神经网络训练函数Newff的使用方法

    一.   介绍新版newff Syntax ·         net = newff(P,T,[S1 S2...S(N-l)],{TF1 TF2...TFNl}, BTF,BLF,PF,IPF,OP ...

  5. MATLAB中神经网络train函数使用说明

    MATLAB中神经网络train( )函数使用说明 函数的语法格式如下: [net, tr]=train(net, P, T, Pi, Ai): train( )函数用于训练创建好的感知器网络,事实上 ...

  6. [转]SAP ABAP中使用Read_Text函数读取项目文本的方法

    SAP ABAP中使用Read_Text函数读取项目文本的方法 使用Read_Text函数来读取文本内容.需要找到相关参数. 下面以采购订单为例: 双击文本,进入文本编辑器. 转到->表头. 显 ...

  7. bp神经网络训练函数选择,BP神经网络训练过程

    BP神经网络的训练集需要大样本吗?一般样本个数为多少? BP神经网络的训练集需要大样本吗?一般样本个数为多少? BP神经网络样本数有什么影响学习神经网络这段时间,有一个疑问,BP神经网络中训练的次数指 ...

  8. Button中command后面函数添加参数解决方法

    Button中command后面函数添加参数解决方法 参考文章: (1)Button中command后面函数添加参数解决方法 (2)https://www.cnblogs.com/smart-ziha ...

  9. Python:numpy库中的一些函数简介、使用方法之详细攻略

    Python:numpy库中的一些函数简介.使用方法之详细攻略 目录 numpy库中的一些函数简介.使用方法 1.np.concatenate() 1.1.函数案例 1.2.函数用法 numpy库中的 ...

最新文章

  1. .NET Core的日志[2]:将日志输出到控制台
  2. 东莞日报报道:比派科技(banana pi)致力于打通物联风创业生态链》
  3. 网站文章中如何设置关键词才更有利于SEO优化?
  4. [转帖]爬过这 6 个坡,你就能对 Linux 操作系统了如指掌
  5. c语言穷举算法 枚举法,c语言枚举法 穷举法 ppt课件
  6. Delphi环境中编写调用DLL的方法和技巧
  7. java 纳秒 毫秒_golang的time包:秒、毫秒、纳秒时间戳输出方式
  8. Object Relational Tool Comparison Dot Net
  9. 精品资源:40个实用的 PSD 贴纸模板《下篇》
  10. 【深度优先搜索】计蒜客:最大蛋糕(最大连通块)
  11. matlab在振动信号处理中的应用_激光测振仪在超声变幅杆振动测试中的应用
  12. 谐波小波 matlab,基于谐波小波的电力系统谐波分析
  13. 室内 Beacon定位室外 GPS 定位 大型场馆融合定位方案
  14. Webmagic爬虫框架
  15. [转]Berkeley DB介绍及主从复制机制
  16. sublime3编程c语言,Sublime Text 3 实现C语言代码的编译和运行(示例讲解)
  17. LoadRunner--并发测试(多用户)
  18. U转串口时,鼠标乱动,解决办法
  19. 图像去燥——TV Loss
  20. Android IBinder的linkToDeath介绍

热门文章

  1. Android搭建简单的socket服务器——基于TCP
  2. 遇见你,爱上你——--献给奇查最美的情书
  3. 名帖68 颜真卿 楷书《多宝塔碑》
  4. 2012计算机三级网络技术成绩查询,2012年全国计算机三级考试成绩查询
  5. 指定函数拟合出现问题
  6. win10隐藏的9种功能 效率提升10倍
  7. 鸿蒙os将用在哪款机型,4月份正式开始,鸿蒙OS即将推送,14款荣耀机型在列,太感动了!...
  8. 搭建实验室3d slam 移动小车 2.3镭神32线激光雷达ROS-RVIZ上方向确定
  9. spring 事物监听机制,同步异步处理
  10. 网络设备的tacacs认证