i have problem with ffnn on matlab

조회 수: 5 (최근 30일)
affan hanafie
affan hanafie 2018년 5월 11일
댓글: affan hanafie 2018년 6월 3일
this is my code
clear
clc
input=[1 2 3];
target=[5 8 4];
n=2;
net=feedforwardnet(n);
net=configure(net,input,target);
net.layers{1}.transferFcn = 'purelin';
net.layers{2}.transferFcn = 'purelin';
ukuran1=size(input);
ukuran2=size(target);
m=ukuran1(1,1); %ini banyak input
o=ukuran2(1,1); %ini banyak output
kk=((m+1+o)*n)+1; %ini banyak bobot
net.iw{1}=[0;0];
net.lw{2}=[0 0];
net.b{1}=[0;0];
net.b{2}=[0];
y=net(input)
why the output (y) always different with my manual computation, can someone help me? maybe there is somethings i didnt know about FFNN matlab that
  댓글 수: 2
Greg Heath
Greg Heath 2018년 5월 11일
clear, clc
input=[1 2 3]; target=[5 8 4];
n=2; net=feedforwardnet(n);
net=configure(net,input,target);
% 1. EXPLICIT CONFIGURATION IS UNNECCESSARY IF YOU TRAIN THE NET
net.layers{1}.transferFcn = 'purelin';
% 2. NON OUTPUT LAYERS SHOULD HAVE NONLINEAR TRANSFER FUNCTIONS
net.layers{2}.transferFcn = 'purelin'; ukuran1=size(input); ukuran2=size(target); m=ukuran1(1,1); %ini banyak input o=ukuran2(1,1); %ini banyak output kk=((m+1+o)*n)+1; %ini banyak bobot net.iw{1}=[0;0]; net.lw{2}=[0 0]; net.b{1}=[0;0]; net.b{2}=[0];
% 3. INITIAL WEIGHTS SHOULD BE RANDOM. YOU CAN ASSIGN RANDOM VALUES, OR USE CONFIGURE OR JUST TRAIN THE NET WHICH WILL AUTOMATICALLY INITIALIZE WEIGHTS.
y=net(input)
% THE NET HAS NO WEIGHTS! YOU NEED TO TRAIN THE NET.
SEE MY ANSWER
GREG
affan hanafie
affan hanafie 2018년 6월 3일
thanks for your answaer

댓글을 달려면 로그인하십시오.

답변 (1개)

Greg Heath
Greg Heath 2018년 5월 11일
close all, clear, clc
% N No. of input and output-target vectors
% I Input dimension
% O Output dimension
% H No. of hidden units
% I-H-O Typical network node topology
% Nw = (I+1)*H+(H+1)*O No. of weights
%
% Ntst = round(0.15*N) Default No. of test vectors
% Nval = Ntst Default No. of validation design vectors
% Ntrn = N-Nval-Ntst Default No. of training design vectors (~0.7*N)
%
% Training vectors: Design vectors used to determine network weight values
% Validation vectors: Design vectors used to stop training when val errors
% increase continually for 6 (default) continuous training epochs
% Test vectors: Nondesign vectors used to obtain UNBIASED performance
% estimates
input=[1 2 3]; target=[5 8 4];
[I N ] = size(input) % [1 3]
[O N ] = size(target)%[ 1 3 ]
plot(input,target)
rng(0) % Allows duplication of results
n=2; net=feedforwardnet(n);
[net tr output error ] = train(net,input,target);
% Normalized Mean Square Error 0<= NMSE <= 1
NMSE = mse(error)/var(target,1) % 4.3684e-26
  댓글 수: 2
Greg Heath
Greg Heath 2018년 5월 11일
1. See the documentation examples in
help feedforwardnet
and
doc feedforwardnet
2. For more examples, search ANSWERS using
greg feedforwardnet
Hope this helps.
Greg
affan hanafie
affan hanafie 2018년 6월 3일
thanks man

댓글을 달려면 로그인하십시오.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by