Home > TNNT_1_07 > @theta_neuron_network > update_structure.m

update_structure

PURPOSE ^

UPDATE_STRUCTURE calculates static network properties

SYNOPSIS ^

function ThNN=update_structure(ThNN)

DESCRIPTION ^

UPDATE_STRUCTURE calculates static network properties

Description:
Function to calculate static network properties to save on computation
time. Properties include the execution order (for non-recursive networks)
and the indices to input and output neurons. This function is called
automatically when a network is constructed.

Syntax:
ThNN=UPDATE_STRUCTURE(ThNN);

Input Parameters:
o ThNN: An object of the theta neuron network class

Output Parameters:
o ThNN: An object of the theta neuron network class now with static
    network properties included.

Example:
>> ThNN=theta_neuron_network
>> ThNN.Weights(1,1)=0.5
>> ThNN=update_structure(ThNN)

See also theta_neuron_network

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function ThNN=update_structure(ThNN)
0002 %UPDATE_STRUCTURE calculates static network properties
0003 %
0004 %Description:
0005 %Function to calculate static network properties to save on computation
0006 %time. Properties include the execution order (for non-recursive networks)
0007 %and the indices to input and output neurons. This function is called
0008 %automatically when a network is constructed.
0009 %
0010 %Syntax:
0011 %ThNN=UPDATE_STRUCTURE(ThNN);
0012 %
0013 %Input Parameters:
0014 %o ThNN: An object of the theta neuron network class
0015 %
0016 %Output Parameters:
0017 %o ThNN: An object of the theta neuron network class now with static
0018 %    network properties included.
0019 %
0020 %Example:
0021 %>> ThNN=theta_neuron_network
0022 %>> ThNN.Weights(1,1)=0.5
0023 %>> ThNN=update_structure(ThNN)
0024 %
0025 %See also theta_neuron_network
0026 
0027 %Copyright (C) 2008 Sam McKennoch <Samuel.McKennoch@loria.fr>
0028 
0029 
0030 %Get Static Inputs and Outputs (to save on computation later)
0031 InputNeurons=[];
0032 OutputNeurons=[];
0033 for j=1:size(ThNN.Weights,1)
0034     if sum(ThNN.Weights(:,j)~=0)==0
0035         InputNeurons=push_unique(InputNeurons, j);
0036     end
0037     if sum(ThNN.Weights(j,:)~=0)==0
0038         OutputNeurons=push_unique(OutputNeurons, j);
0039     end
0040 end
0041 ThNN.InputNeurons=InputNeurons;
0042 ThNN.OutputNeurons=OutputNeurons;
0043 ConnectionMatrix=(ThNN.Weights~=0);
0044 ThNN.RecursionFlag=logical(sum(sum(ConnectionMatrix^(size(ConnectionMatrix,1)))));
0045 
0046 
0047 %Get execution order if is non-recursive
0048 NeuronQueue=[];
0049 NumNeurons=length(ThNN.Neurons);
0050 if ~ThNN.RecursionFlag
0051     NeuronQueue=[];
0052 
0053     for j=1:length(ThNN.InputNeurons)
0054         NeuronQueue=push_unique(NeuronQueue, get_output_neurons(ThNN,ThNN.InputNeurons(j))');
0055     end
0056 
0057     Pos=1;
0058     while length(NeuronQueue)<(NumNeurons-length(ThNN.InputNeurons))
0059         CurrentNeuron=NeuronQueue(Pos);
0060         NeuronQueue=push_unique(NeuronQueue, get_output_neurons(ThNN,CurrentNeuron)');
0061         Pos=Pos+1;
0062         if Pos>length(NeuronQueue)
0063             disp('Warning in update structure: Not all neurons are connected and may not be processed');
0064             break;
0065         end
0066     end
0067 end
0068 ThNN.NeuronQueue=NeuronQueue;
0069 
0070 for j=1:NumNeurons
0071     ThNN.RelativeInputNeurons{j}=get_input_neurons(ThNN,j);
0072     ThNN.RelativeOutputNeurons{j}=get_output_neurons(ThNN,j);
0073 end

Generated on Wed 02-Apr-2008 15:16:32 by m2html © 2003