train_noise_snn.m

来自「神经网络的工具箱, 神经网络的工具箱,」· M 代码 · 共 74 行

M
74
字号
function [noise_net, noise_record] = train_noise_snn(net, noise_data, blocksize)%TRAIN_NOISE_SNN Train a network on noise prediction.%% Syntax%%  [noise_net, noise_tr_info] = train_noise_snn(net, noise_data)%% Description%%  TRAIN_NOISE_SNN takes the connection weights, biases and transfer%  functions of 'net' and replaces the transfer function of the last layer %  with an exponential transfer function. Then in a training%  procedure, only the connection weights and biases in this last%  layer are adjusted to minimize the cost on 'noise_data'.%%  TRAIN_NOISE_SNN(net, noise_data)%    net         - a net_struct%    noise_data  - a wcfdata_struct with a training data set for the%                  noise.%  and returns %    noise_net     - a net_struct predicting noise.%    noise_tr_info - a struct containing info on the training process.%% See also%%  C_PREDICTION_SNN%%#function lintf_snn exptf_snn logsigtf_snn radbastf_snn tansigtf_snn if (nargin < 3)   blocksize = 1;endL = net.numLayers;MU = size(noise_data.P,2);yh = feval(net.transferFcn{1}, net.weights{1}*noise_data.P + ...                               repmat(net.biases{1}, 1, MU));if (L>1)   for l = 2:(L-1)       yh = feval(net.transferFcn{l}, net.weights{l}*yh + ...                                      repmat(net.biases{l},1,MU));   endendnoise_data.P = yh;N = size(net.biases{net.numLayers},1);Nh = size(net.biases{net.numLayers-1},1);train_net = net_struct_snn([Nh N], {'exptf_snn'}, 'traincgp_snn');train_net.costFcn.name = 'wcf_snn';train_net.costFcn.fn = 'loglikelihood_snn';train_net.costFcn.a = [];if isfield(noise_data, 'useT')   for i = 1:N       mu = find(~isnan(noise_data.T(i,:)));       NR = size(mu, 2);       train_net.biases{1}(i) = log(1/NR * sum(exp(noise_data.T(i,mu)), 2));    endelse   train_net.biases{1} = log(1/MU * sum(exp(noise_data.T), 2)); endtrain_net.weights{1} = zeros(N, Nh); [train_net, noise_record] = train_bootstrap_snn(train_net, noise_data, blocksize);noise_net = net;noise_net.transferFcn{L} = 'exptf_snn';%noise_net.transferFcn{L} = 'logsig';noise_net.biases{L} = train_net.biases{1};noise_net.weights{L} = train_net.weights{1};

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?