?? wcf_snn.m
字號:
function [E, Eimu] = wcf_snn(X, net, data)%WCF_SNN Weighted cost function.%%Syntax%% 1. [cost, Eimu] = wcf_snn(net, wcfdata)% 2. [cost, Eimu] = wcf_snn(X, net, wcfdata)% 3. costfcn_struct = wcf_snn('pdefaults')%%Description%% WCF_SNN computes the following cost function:%% cost(y, t) = sum_{ \{i, \mu | \Delta_{i\mu} = 1\} } % a_i g_{\mu} e^i(y_{i\mu}, t_{i\mu})%% with:% i - output index% \mu - pattern index% a_i - output weight% g_{\mu} - pattern weight% e^i - error function for output i% y_{i\mu} - prediction for output i, pattern \mu.% t_{i\mu} - target for output i, pattern \mu.% \Delta_{i\mu} - parameter controlling over which outputs for% which patterns the summation is done%% 1. WCF_SNN(net, wcfdata) takes% net - a net_struct with error function WCF_SNN.% wcfdata - a wcfdata_struct containing input/output patterns. % and returns% cost - the total weighted cost. % Eimu - the weighted error for each (output, pattern) pair.%% 2. WCF_SNN(X, net, wcfdata) takes% X - additional vector with connection weights and biases,% which are used to compute the cost instead of the% connenction weights and biases in 'net'.%% 3. The field 'costFcn' of 'net' must contain a stucture with the cost% function parameters. The default parameters can be set with%% net = set_net_costfcn_snn(net, wcf_snn('pdefaults'));%% (NL = #outputs)%%Example%% MU = 5;% P = rand(2, MU);% T = rand(1, MU); % gmu = [1 2 2 1 1];% Delta = [1 0 1 0 1];% wcfdata = wcfdata_struct_snn(P, T, gmu, Delta)% net = net_struct_snn([2 4 1], {'tansigtf_snn', 'lintf_snn'},'trainlm_snn');% wcf_snn(net, wcfdata)%% See Also%% NET_STRUCT_SNN, WCF_STRUCT_SNN, WCFDATA_STRUCT_SNN%if (isstr(X)) switch lower(X) case 'deriv', E = 'dwcf_snn'; case '2deriv', E = 'd2wcf_snn'; case 'argmin', E = 'argmin_wcf_snn'; case 'pdefaults', E = wcf_struct_snn; otherwise, error('Unrecognized code.') end returnendif (nargin == 2) % wcf_snn(net, data) data = net; net = X;elseif (nargin == 3) % wcf_snn(X, net, data) net = setx_snn(net, X);else error('Incorrect number of input arguments');end% special: if isfield(data.Y) then ignore network outputs and compute% cost from E(data.Y, data.T);if isfield(data, 'Y') y = data.Y;else y = simff_snn(net, data);endg = getg_snn(net, data);errf = net.costFcn.fn;[E, Eimu] = wef_snn(y, data.T, g, errf);
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -