READLABEL load neuron labels from filePath and assign them to network [ network ] = readLabel( network, filePath ) This function load neuron labels from filePath and assign them to network Input: network: a network structure filePath: path of neuron label file that contain which nodes are input neurons, which are output neurons and which are inter neurons Output: network: a network structure
0001 function [ network ] = readLabel( network, filePath ) 0002 % READLABEL load neuron labels from filePath and assign them to network 0003 % 0004 % [ network ] = readLabel( network, filePath ) 0005 % This function load neuron labels from filePath and assign them to network 0006 % 0007 % Input: 0008 % network: a network structure 0009 % filePath: path of neuron label file that contain which nodes are input 0010 % neurons, which are output neurons and which are inter neurons 0011 % 0012 % Output: 0013 % network: a network structure 0014 0015 % --------- 0016 % Yen-Nan Lin, NTHU, 2010-2014, Matlab 2012a 0017 0018 countLine = 1; 0019 fileID = fopen(filePath, 'r'); 0020 while ~feof(fileID) 0021 strLine = fgetl(fileID); 0022 if strLine(1) == '#' 0023 continue; 0024 % if label is using number to represent 0025 elseif ~isempty( regexp(strLine(1), '[0-9]') ) 0026 numericLine = strread(strLine, '%d'); 0027 % if label is using string to represent 0028 elseif isempty( regexp(strLine(1), '[0-9]') ) 0029 numericLine = strread(strLine, '%s'); 0030 end 0031 numericLine = numericLine'; 0032 switch countLine 0033 case 1 0034 network.label = numericLine; 0035 case 2 0036 network.inputList = numericLine; 0037 case 3 0038 network.outputList = numericLine; 0039 end 0040 countLine = countLine + 1; 0041 end 0042 fclose(fileID); 0043 end 0044