?? xnewff.m
字號:
function xNewff
% xNewff.m
% 本程序用newff()創(chuàng)建兩層前向網(wǎng)絡(luò),并用sim()對網(wǎng)絡(luò)進行仿真
%
% Author: HUANG Huajiang
% Copyright 2002 UNILAB Research Center,
% East China University of Science and Technology, Shanghai, PRC
% $Revision: 1.0 $ $Date: 2003/01/10 $
%
% [Ref] MATLAB demo, Mathworks Co.
clear all
clc
% 輸入樣本p和目標t
p = -1:.1:1;
t = [-.9602 -.5770 -.0729 .3771 .6405 .6600 .4609 ...
.1336 -.2013 -.4344 -.5000 -.3930 -.1647 .0988 ...
.3072 .3960 .3449 .1816 -.0312 -.2189 -.3201];
% 用newff()創(chuàng)建兩層前向網(wǎng)絡(luò),網(wǎng)絡(luò)輸入范圍是[-1 1],第一層有10個
% TANSIG神經(jīng)元,第二層有1個PURELIN神經(jīng)元。訓(xùn)練函數(shù)為TRAINLM()
net = newff([-1 1],[10 1],{'tansig' 'purelin'},'trainlm');
% 對前向網(wǎng)絡(luò)進行仿真,并將網(wǎng)絡(luò)輸出值對目標值作圖
y = sim(net,p)
plot(p,t,'o',p,y,'x') %
title('訓(xùn)練向量 (訓(xùn)練1個epoch)');
xlabel('輸入向量 p');
ylabel('目標向量 t');
% Here 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,'o',p,y,'*-')
title('訓(xùn)練向量 (訓(xùn)練50個epoch)');
xlabel('輸入向量 p');
ylabel('目標向量 t');
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -