I have some training data and some test data. Can anyone tell me is training data is the input data or it is desired data in wavelet neural network?

3 次查看(过去 30 天)
I have EEG signals obtained from MIT_BIH. I want to use some of it for training data for seizure detection and some for testing purposes. I have the following code for training in wavelet neural network. What is desired output and input for my case? clear all; clc; close all; %initiate of data P=3 %number of sample m=1%number of input node n=20%number of hidden node N=1%number of ouptut node % %a(n) b(n) scale and shifting parameter matrix %x(P,m) input matrix of P sample %net(P,n) ouput of hidden node %y(P,N) output of network %d(P,N) ideal output of network % phi(P,n) ouput of hidden node wavelet funciton %W(N,n)weight value between ouput and hidden %WW(n,m) weight value between hidden and input node x=[4;5;6] d=[1.3;3.6;6.7] W=rand(N,n) WW=rand(n,m) a=ones(1,n) for j=1:n b(j)=j*P/n; end %%%%%%%%%%%%%%%%%% %EW(N,n) gradient of W %EWW(n,m) gradient of WW %Ea(n) gradient of a %Eb(n) gradient of b %%%%%%%%%%%%%%] epoch=1; epo=100;%???Purpose of it??? error=0.05; err=0.01; delta =1; lin=0.5; while (error>=err && epoch<=epo)
u=0;%u is the middle variant
%caculation of net input
for p=1:P
for j=1:n
u=0;
for k=1:m
u=u+WW(j,k)*x(p,k);%%%probably vj(n)
end
net(p,j)=u;
end
end
%calculation of morlet 0r mexican wavelet output
for p=1:P
for j=1:n
u=net(p,j);
u=(u-b(j))/a(j);
phi(p,j)=cos(1.75*u)*exp(-u*u/2); %morlet wavelet
%phi(p,j)=(1-u^2)*exp(-u*u/2); %mexican hat wavelet
end
end
%calculation of output of network
for p=1:P
for i=1:N
u=0;
for j=1:n
u=u+W(i,j)*phi(p,j);
end
y(p,i)=delta*abs(u);
end
end
%calculation of error of output
u=0;
for p=1:P
for i=1:N
%u=u+abs(d(p,i)*log(y(p,i))+(1-d(p,i)*log(1-y(p,i))));
u=u+(d(p,i)-y(p,i))^2;
end
end
%u=u/2
error=u;
%calculate of gradient of network
for i=1:N
for j=1:n
u=0;
for p=1:P
u=u+(d(p,i)-y(p,i))*phi(p,j);
end
EW(i,j)=u;
%EW(i,j)=-u;%the resule would be wrong
end
end
for j=1:n
for k=1:m
u=0;
for p=1:P
for i=1:N
u=u+(d(p,i)-y(p,i))*W(i,j)*phi(p,j)*x(p,k)/a(j) ;
end
end
EWW(j,k)=u;
%EWW(j,k)=u the result would be wrong
end
end
for j=1:n
u=0;
for p=1:P
for i=1:N
u=u+(d(p,i)-y(p,i))*W(i,j)*phi(p,j)/a(j) ;
end
end
Eb(j)=u;
end
for j=1:n
u=0;
for p=1:P
for i=1:N
u=u+(d(p,i)-y(p,i))*W(i,j)*phi(p,j)*((net(p,j)-b(j))/b(j))/a(j) ;
end
end
Ea(j)=u;
end
%adjust of weight value
WW=WW-lin*EWW;
W=W-lin*EW;
a=a-lin*Ea;
b=b-lin*Eb;
%number of epoch increase by 1
epoch=epoch+1;
end plot(x,d,x,y,'--')

回答(2 个)

Greg Heath
Greg Heath 2018-2-12
编辑:Greg Heath 2018-2-12
Your description should be reformatted to prevent confusion.
data = design + test
design = training + validation
data = training + validation + test
EACH OF THESE 3 SUBSETS CONSIST OF 2 PARTS
DATASUBSET = INPUT + TARGET
default MATLAB division ratios = 0.7/0.15/0.15
HOWEVER, YOU CAN MODIFY THESE RATIOS
nontraining = validation + test
TRAINING: used to calculate weights and biases
VALIDATION: used DURING training to help make sure net works
well on nontraining data. NOT directly involved in
calculating weight values
TEST: used to obtain UNBIASED estimate of performance on
ALL (i.e., TEST + UNKNOWN) data not involved in
training or validation
Hope this helps.
Thank you for formally accepting my answer
Greg
  1 个评论
Naznin Sultana
Naznin Sultana 2018-2-13
Thanks for answering. however i am looking at a WNN training code where input x and output y (called desired value) was used. My question was if i have EEG features as training set, what i will set as desired output?

请先登录,再进行评论。


Greg Heath
Greg Heath 2018-2-13
Correct notation:
x input
t target = desired output
y output = net(x)
e error = t - y
% Reference output and MeanSquareError
tref = mean(t',2)
MSEref = mean((t-tref).^2)
= mean(var(t'),1)
[ net tr y e ] = train(net,x,t);
% y = net(x); e = t-y;
MSE = mse(e)
NMSE = MSE/NMSEref
Rsquare = 1 - NMSE % See Wikipedia
% For training details
tr = tr
Hope this helps
Thank you for formally accepting my answer
Greg

类别

Help CenterFile Exchange 中查找有关 AI for Signals and Images 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by