problems with training function LVQ (example from help does not work)

조회 수: 2 (최근 30일)
Hi all, please I need your help !
example (LVQ) from help does not work
P = [-3 -2 -2 0 0 0 0 2 2 3; 0 1 -1 2 1 -1 -2 1 -1 0];
Tc = [1 1 1 2 2 2 2 1 1 1];
T = ind2vec(Tc);
targets = full(T);
net = newlvq(P,4,[.6 .4]);
Y = sim(net,P);
Yc = vec2ind(Y);
net.trainParam.epochs = 150;
net = train(net,P,T);
In training process after 2 interactions training was stop. (My system 2011a,a check on 2009b - the same thing).
Maybe I'm doing something wrong?

채택된 답변

Greg Heath
Greg Heath 2011년 10월 2일
Nothing is wrong...it is a simple problem that only requires 2 or 3 epochs to obtain 0 error. You just didn't follow through.
close all, clear all, clc
% NOTE: Remove end semicolons to monitor outputs
P = [-3 -2 -2 0 0 0 0 2 2 3; 0 1 -1 2 1 -1 -2 1 -1 0]
Tc = [1 1 1 2 2 2 2 1 1 1]
T = ind2vec(Tc)
targets = full(T)
net = newlvq(minmax(P),4,[.6 .4]); % Old Version
% With no training
IW = net.IW{1,1}
LW = net.LW{2,1}
b = net.b(1,:)
Y = sim(net,P)
Yc = vec2ind(Y)
% ... Yc = [ 1 1 1 1 1 1 1 1 1 1 ]
% resulting in a classification error of 40%
%Training with defaults
net = train(net,P,T);
% Converges in 3 epochs
IW = net.IW{1,1}
LW = net.LW{2,1}
b = net.b(1,:)
Y = sim(net,P)
Yc = vec2ind(Y)
% ... Yc = [ 1 1 1 2 2 2 2 1 1 1 ]
% resulting in a classification error of 0% !!!
Hope this helps.
Greg

추가 답변 (1개)

Greg Heath
Greg Heath 2011년 10월 2일
Sorry for the formatting. This text editor sucks.
Greg
  댓글 수: 1
Walter Roberson
Walter Roberson 2011년 10월 2일
Put a newline before the code to be formatted. Highlight the code to be formatted. Click on the "{} Code" button. Code will now be formatted in the preview.

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

카테고리

Help CenterFile Exchange에서 Sequence and Numeric Feature Data Workflows에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by