error message"Network cintains a zero-delay loop"
15 views (last 30 days)
Show older comments
clear
clc
load RV_IN.txt;
load RV_OUT.txt;
k=(1:2064);
[m,n]=sort(k);
input_train_1=RV_IN(n(2:480),2:4)';
input_train_2=RV_IN(n(2:480),5:7)';
output_train=RV_OUT(n(2:480),:)';
y_1 = con2seq(input_train_1);
y_2 = con2seq(input_train_2);
Pi_1 = RV_IN(n(1),2:4)';
Pi_2 = RV_IN(n(1),5:7)';
Pi_1 = con2seq(Pi_1);
Pi_2 = con2seq(Pi_2);
Pi = {Pi_1;Pi_2};
t = con2seq(output_train);
X_1= {y_1;y_2};
input_test_1= RV_IN(n(479:2064),2:4)';
input_test_2= RV_IN(n(479:2064),5:7)';
output_test = RV_OUT(n(479:2064),:)';
y_3 = con2seq(input_test_1);
y_4 = con2seq(input_test_2);
X_2 = {y_3;y_4};
net = network;
net.numInputs = 2;
net.numLayers = 3;
net.biasConnect = [1; 1; 1];
net.inputConnect = [1 1; 1 1; 0 0];
net.layerConnect = [0 0 1;0 0 1;0 1 1];
net.outputConnect = [0 0 1];
net.inputs{1}.exampleInput = y_1;
net.inputs{2}.exampleInput = y_2;
net.inputs{1}.processFcns = {'mapminmax'};
net.inputs{2}.processFcns = {'mapminmax'};
net.layers{1}.size = 6;
net.layers{1}.transferFcn = 'radbas';
net.layers{2}.size = 6;
net.layers{2}.transferFcn = 'radbas';
net.layers{3}.size = 6;
net.layers{3}.transferFcn = 'purelin';
net.inputWeights{2,1}.delays = [0 1];
net.inputWeights{1,2}.delays = [0 1];
net.layerWeights{1,3}.delays = [1 2];
net.layerWeights{2,3}.delays = [1 2];
net.layers{1}.netInputFcn = 'netprod';
net.layers{2}.netInputFcn = 'netprod';
net.layers{3}.netInputFcn = 'netsum';
net.layers{1}.initFcn = 'initwb';
net.layers{2}.initFcn = 'initwb';
net.performFcn = 'mse';
net.inputWeights{1,1}.weightFcn = 'dist';
net.inputWeights{1,2}.weightFcn = 'dist';
net.inputWeights{2,1}.weightFcn = 'dist';
net.inputWeights{2,2}.weightFcn = 'dist';
net.layerWeights{3,2}.weightFcn = 'dotprod';
net.layerWeights{3,1}.weightFcn = 'dotprod';
net.layerWeights{1,3}.weightFcn = 'dist';
net.layerWeights{2,3}.weightFcn = 'dist';
net.adaptFcn = 'trains';
net.divideFcn = 'dividerand';
net.trainFcn = 'trainlm';
net.outputs{3}.exampleOutput = t;
net.plotFcns = {'plotperform','plottrainstate'};
% net.outputs{2}.processFcns = {'mapminmax'};
net.biases{1}.learn = 1;
net.biases{1}.learnFcn = 'learngdm';
net.biases{2}.learn = 1;
net.biases{2}.learnFcn = 'learngdm';
net.biases{3}.learn = 1;
net.biases{3}.learnFcn = 'learngdm';
net.inputWeights{1,1}.learn = 1;
net.inputWeights{1,2}.learn = 1;
net.inputWeights{2,1}.learn = 1;
net.inputWeights{2,2}.learn = 1;
net.layerWeights{3,2}.learn = 1;
net.layerWeights{3,1}.learn = 1;
net.layerWeights{1,3}.learn = 1;
net.layerWeights{2,3}.learn = 1;
net.inputWeights{1,1}.learnFcn = 'learngdm';
net.inputWeights{1,2}.learnFcn = 'learngdm';
net.inputWeights{2,1}.learnFcn = 'learngdm';
net.inputWeights{2,2}.learnFcn = 'learngdm';
net.layerWeights{3,2}.learnFcn = 'learngdm';
net.layerWeights{3,1}.learnFcn = 'learngdm';
net.layerWeights{1,3}.learnFcn = 'learngdm';
net.layerWeights{2,3}.learnFcn = 'learngdm';
net.trainParam.epochs=6000;
net.trainParam.lr=0.001;
% net.trainParam.lr=0.5;
net.trainParam.goal=0.00004;
net = train(net,X_1,t,Pi);
Y = sim(net,X_1);
Y=cell2mat(Y);
figure(1)
plot(output_train(1,:),'-r');
hold on;
plot(Y(1,:),'-b');
title('V')
I have created a neural networks that I am trying to train using the Matlab Neural Network toolbox. But quite a few times, the program crashes giving me this error message "Network contains a zero-delay loop". What does this error mean? What could have gone wrong with the particular network being trained??
0 Comments
Answers (1)
Adel Fazel
on 23 Apr 2013
Hi Lucky,
The basic idea is that when connecting outer layers to inner layers, you'd need to introduce delay (otherwise it doesn't make sense). More specifically, assume we have a feedforward neural network and we want to connect output layer to hidden layer (or hidden to hidden), then what values are going to be fed back?? Answer: The values from Delay times back. If you connect outer layer to inner layer (or same levels) and do not alter the delays you get that error. To fix this issue simply define desired lag an example is given: net.layerWeights{i,j}.delays=1;
Adel
1 Comment
See Also
Categories
Find more on Define Shallow Neural Network Architectures in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!