function slide=demolin6
% This is a slideshow file for use with playshow.m and makeshow.m
% To see it run, type 'playshow demolin6', 

% Copyright 1992-2000 The MathWorks, Inc.
% $Revision: 1.9 $  $Date: 2000/06/15 04:17:49 $

if nargout<1,
  playshow demolin6
else
  %========== Slide 1 ==========

  slide(1).code={
   'slideData=nnslides(''start'',slideData,''Linearly Dependent Problem'');',
   '' };
  slide(1).text={
   'NEWLIN - Creates a linear layer.',
   'TRAIN  - Trains a neural network.',
   'SIM  - Simulates a neural network.',
   'Using the above functions a linear neuron is trained to find the minimum error solution for a problem with linearly dependent input vectors.  If a linear dependence in input vectors is not matched in the target vectors, the problem is nonlinear and does not have a zero error linear solution.'};

  %========== Slide 2 ==========

  slide(2).code={
   'slideData=nnslides(''blank'',slideData);',
   ' P = [1.0   2.0   3.0; 4.0   5.0   6.0];' };
  slide(2).text={
   'P defines three 2-element input patterns (column vectors):',
   '>> P = [1.0   2.0   3.0;',
   '            4.0   5.0   6.0];',
   'Note that 0.5 times the sum of (column) vectors 1 and 3 results in vector 2.  This is called linear dependence.',
   ''};

  %========== Slide 3 ==========

  slide(3).code={
   'T = [0.5 1.0 -1.0];',
   '' };
  slide(3).text={
   'T defines an associated 1-element target (column vectors):',
   '>> T = [0.5 1.0 -1.0];',
   '',
   'Note that 0.5 times the sum of -1.0 and 0.5 does not equal 1.0.  Because the linear dependence in P is not matched in T this problem is nonlinear and does not have a zero error linear solution.'};

  %========== Slide 4 ==========

  slide(4).code={
   'maxlr=maxlinlr(P,''bias'');',
   'net=newlin([0 10;0 10],1,[0],maxlr);' };
  slide(4).text={
   'MAXLINLR finds the fastest stable learning rate for TRAINWH.',
   '>> maxlr=maxlinlr(P,''bias'');',
   'NEWLIN creates a linear neuron.',
   '>> net=newlin([0 10;0 10],1,[0],maxlr);',
   'NEWLIN takes these arguments: 1) Rx2 matrix of min and max values for R input elements, 2) Number of elements in the output vector, 3) Input delay vector, and 4) Learning rate.'};

  %========== Slide 5 ==========

  slide(5).code={
   'slideData=nnslides(''blank'',slideData);',
   'net.trainParam.show = 50;',
   'net.trainParam.epochs =500;',
   'net.trainParam.goal = 0.001;',
   '' };
  slide(5).text={
   'TRAIN uses the Widrow-Hoff rule to train linear networks by default.',
   'We will display each 50 epochs and train for a maximum of 40 epochs.',
   '>> net.trainParam.show = 50;    % Frequency of progress displays (in epochs).',
   '>> net.trainParam.epochs = 500;    % Maximum number of epochs to train.',
   '>> net.trainParam.goal = 0.001;  % Sum-squared error goal.',
   ''};

  %========== Slide 6 ==========

  slide(6).code={
   'slideData=nnslides(''lock'',slideData);',
   'slideData=nnslides(''axes'',slideData);',
   'more off;',
   ' [net,tr]=train(net,P,T);',
   'set(gcf,''name'',''Linearly Dependent Problem'');',
   'slideData=nnslides(''unlock'',slideData);' };
  slide(6).text={
   'Now the network is trained on the inputs P and targets T.',
   '>> [net,tr]=train(net,P,T);',
   'Please wait until the training is complete before continuing.',
   'Note that, due to the linear dependence between input vectors, the problem did not reach the error goal represented by the black line.'};

  %========== Slide 7 ==========

  slide(7).code={
   'p = [1.0; 4];',
   'a = sim(net,p);',
   'slideData=nnslides(''text'',slideData,[''a = '' num2str(a)]);',
   '' };
  slide(7).text={
   'We can now test the associator with one of the original inputs, [1; 4] , and see if it returns the target, 0.5.',
   '>> p = [1.0; 4];',
   '>> a = sim(net,p)',
   '(see above for result)',
   'The result is not 0.5 as the linear network could not fit the nonlinear problem caused by the linear dependence between input vectors.'};
end