📄 simff_avr_snn.m
字号:
function [y_av, err_estimate] = simff_avr_snn(nets, alpha, P)%SIMFF_AVR_SNN Compute weighted ensemble average output.%% Syntax%% [y_av, err_estimate] = simff_avr_snn(nets, alpha, P)%% Description%% SIMFF_AVR_SNN takes% nets - [1 x M] struct array of net_structs with an ensemble of% trained networks. % alpha - [1 x M] matrix of weighting factors. % P - [N0 x MU] matrix of input patterns.% and returns% y_av - [NL x MU] matrix of averaged outputs.% err_estimate - [NL x MU] matrix of ensemble average error estimate. %% (M = #networks in ensemble; N0 = #inputs; MU = #patterns)%% Algorithm%% See: T. Heskes; Balancing between bagging and bumping.% Advancesin Neural Information Processing Systems 9, pages% 466-472, Cambridge, 1997, MIT Press. %% See also%% BALANCE_SNN%M = size(nets,2);N = size(nets(1).biases{nets(1).numLayers},1);[NI, MU] = size(P);errf = nets(1).costFcn.fn;ym = zeros(N, MU, M);for m = 1:M ym(:,:,m) = simff_snn(nets(1,m), P); endalpha = alpha/(sum(alpha,1));y_av = average_outputs_snn(ym, alpha, errf);%#function se_snn%#function relerr_snn%#function loglikelihood_snn%#function crosslogistic_snn%#function crossentropy_snnif (nargout > 1) if isstr(errf) err_estimate = (1/(1-sumsqr_snn(alpha))) * ... reshape(... reshape(... feval(errf, ym, reshape(repmat(y_av,1,M), [N MU M])), ... [N*MU M]) * alpha, ... [N MU]); elseif iscell(errf) for i = 1:N err_estimate(i,:) = (1/(1-sumsqr_snn(alpha))) * ... reshape(... reshape(... feval(errf{i}, reshape(ym(i,:,:), [MU M]), ... reshape(repmat(y_av(i,:),1,M), [MU M])), ... [MU M]) * alpha, ... [1 MU]); end else error('Incorrect format for output errorfunction'); endend
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -