diff options
| author | ziejd2 | 2017-09-28 15:04:40 -0500 |
|---|---|---|
| committer | ziejd2 | 2017-09-28 15:04:40 -0500 |
| commit | 8070dc963753142bb86c4ed698d91fd623ed28e7 (patch) | |
| tree | d0f6dd8fc46a49b819aa55c1a90faa14d8448883 /sourcecodes/bnt-master/netlab3.3/consist.m | |
| parent | 7cc31810d53176e805532b2789955f4eedbce6bb (diff) | |
| download | BNW-8070dc963753142bb86c4ed698d91fd623ed28e7.tar.gz | |
BNW using Octave instead of Matlab.
This version of BNW should perform the same as the original version. The only difference is that it uses Octave instead of Matlab when running BayesNet Toolbox during parameter learning. I am calling this BNW_1.02. It can be accessed at: compbio.uthsc.edu/BNW_1.02
Diffstat (limited to 'sourcecodes/bnt-master/netlab3.3/consist.m')
| -rw-r--r-- | sourcecodes/bnt-master/netlab3.3/consist.m | 87 |
1 files changed, 87 insertions, 0 deletions
diff --git a/sourcecodes/bnt-master/netlab3.3/consist.m b/sourcecodes/bnt-master/netlab3.3/consist.m new file mode 100644 index 00000000..9305b265 --- /dev/null +++ b/sourcecodes/bnt-master/netlab3.3/consist.m @@ -0,0 +1,87 @@ +function errstring = consist(model, type, inputs, outputs) +%CONSIST Check that arguments are consistent. +% +% Description +% +% ERRSTRING = CONSIST(NET, TYPE, INPUTS) takes a network data structure +% NET together with a string TYPE containing the correct network type, +% a matrix INPUTS of input vectors and checks that the data structure +% is consistent with the other arguments. An empty string is returned +% if there is no error, otherwise the string contains the relevant +% error message. If the TYPE string is empty, then any type of network +% is allowed. +% +% ERRSTRING = CONSIST(NET, TYPE) takes a network data structure NET +% together with a string TYPE containing the correct network type, and +% checks that the two types match. +% +% ERRSTRING = CONSIST(NET, TYPE, INPUTS, OUTPUTS) also checks that the +% network has the correct number of outputs, and that the number of +% patterns in the INPUTS and OUTPUTS is the same. The fields in NET +% that are used are +% type +% nin +% nout +% +% See also +% MLPFWD +% + +% Copyright (c) Ian T Nabney (1996-2001) + +% Assume that all is OK as default +errstring = ''; + +% If type string is not empty +if ~isempty(type) + % First check that model has type field + if ~isfield(model, 'type') + errstring = 'Data structure does not contain type field'; + return + end + % Check that model has the correct type + s = model.type; + if ~strcmp(s, type) + errstring = ['Model type ''', s, ''' does not match expected type ''',... + type, '''']; + return + end +end + +% If inputs are present, check that they have correct dimension +if nargin > 2 + if ~isfield(model, 'nin') + errstring = 'Data structure does not contain nin field'; + return + end + + data_nin = size(inputs, 2); + if model.nin ~= data_nin + errstring = ['Dimension of inputs ', num2str(data_nin), ... + ' does not match number of model inputs ', num2str(model.nin)]; + return + end +end + +% If outputs are present, check that they have correct dimension +if nargin > 3 + if ~isfield(model, 'nout') + errstring = 'Data structure does not conatin nout field'; + return + end + data_nout = size(outputs, 2); + if model.nout ~= data_nout + errstring = ['Dimension of outputs ', num2str(data_nout), ... + ' does not match number of model outputs ', num2str(model.nout)]; + return + end + +% Also check that number of data points in inputs and outputs is the same + num_in = size(inputs, 1); + num_out = size(outputs, 1); + if num_in ~= num_out + errstring = ['Number of input patterns ', num2str(num_in), ... + ' does not match number of output patterns ', num2str(num_out)]; + return + end +end |
