用newff模拟sin函数

本文介绍了如何使用MATLAB中的newff函数创建前馈反向传播神经网络来模拟sin函数。通过设置网络参数如学习速率、训练步数等,并利用sin函数在特定区间内的21个均匀分布点作为训练集,最终实现了对sin函数的有效模拟。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

用newff模拟sin函数

% http://blog.youkuaiyun.com/superdont 我思故我在 P=-1:0.1:1; %建立目标值,是sin曲线上均匀取到的21个点 T=0:0.314:6.28 T=sin(T); %创建网络 net=newff(minmax(P),[5,1],{'tansig','purelin'},'traingda'); %newff :Create a feed-forward backpropagation network %traingda: TRAINGDA Gradient descent with adaptive lr backpropagation. net.trainParam.show = 50; %系统每50步显示一次训练误差的变化曲线 net.trainParam.lr = 0.05; %学习速率 net.trainParam.lr_inc = 1.08; %Ratio to increase learning rate net.trainParam.lr_dec = 0.6; %Ratio to decrease learning rate net.trainParam.epochs = 2000; %训练步数 net.trainParam.goal = 9.5238e-004; % sse=0.02 %训练 网络 [net,tr]=train(net,P,T); % train trains a network net according to net.trainFcn and net.trainParam. % train(NET,P,T,Pi,Ai,VV,TV) takes, % net -- Neural Network 函数返回值,训练后的神经网络 % P -- Network inputs % T -- Network targets, default = zeros % Pi -- Initial input delay conditions, default = zeros % Ai -- Initial layer delay conditions, default = zeros % VV -- Structure of validation vectors, default = [] % TV -- Structure of test vectors, default = [] % and returns, % net -- New network % TR -- Training record (epoch and perf) 函数返回值,训练记录,步数和性能 % Y -- Network outputs % E -- Network errors. % Pf -- Final input delay conditions % Af -- Final layer delay conditions figure(1) plot(tr.lr); figure(2) plot(tr.perf); %%显示预测结果 %应用生成的网络对P进行模拟 T1=sim(net,P); figure(3); %显示目标值 plot(P,T,'r*'); hold on; %显示模拟值 plot(P,T1,'g*');

新版Matlab中神经网络训练函数Newff的详细讲解-新版Matlab中神经网络训练函数Newff的使用方法.doc 本帖最后由 小小2008鸟 于 2013-1-15 21:42 编辑 新版Matlab中神经网络训练函数Newff的详细讲解 一、   介绍新版newffSyntax·          net = newff],{TF1 TF2...TFNl}, BTF,BLF,PF,IPF,OPF,DDF) Descriptionnewff],{TF1 TF2...TFNl}, BTF,BLF,PF,IPF,OPF,DDF) takes several arguments PR x Q1 matrix of Q1 sample R-element input vectorsTSN x Q2 matrix of Q2 sample SN-element target vectorsSiSize of ith layer, for N-1 layers, default = [ ]. TFiTransfer function of ith layer. (Default = 'tansig' for hidden layers and 'purelin' for output layer.)BTFBackpropagation network training function BLFBackpropagation weight/bias learning function IPFRow cell array of input processing functions. OPFRow cell array of output processing functions. DDFData divison function ExamplesHere 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;The network is simulated and its output plotted against the targets.·          Y = sim;plotThe network is trained for 50 epochs. Again the network's output is plotted.·          net.trainParam.epochs = 50;net = train;Y = sim; plot 二、   新版newff与旧版newff调用语法对比 Example1比如输入input(6*1000),输出output为(4*1000),那么旧版定义:net=newff,[14,4],{'tansig','purelin'},'trainlm');新版定义:net=newff; Example2比如输入input(6*1000),输出output为(4*1000),那么旧版定义:net=newff,[49,10,4],{'tansig','tansig','tansig'},'traingdx');新版定义:net=newff; 更详细请看word文档 新版Matlab中神经网络训练函数Newff的使用方法.doc
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值