📄 net_struct_snn.m
字号:
function net = net_struct_snn (s, tf, trainFcn)%NET_STRUCT_SNN Create a feed-forward network in net_struct format.%% Syntax%% net_struct = net_struct_snn([S0 S1 ... SL], {TF1 TF2 ... TFL})% net_struct = net_struct_snn([S0 S1 ... SL], {TF1 TF2 ... TFL}, trainFcn)% net_struct = net_struct_snn(...% [S0 S1 ... SL], {TF1 TF2 ... TFL}, trainFcn, costFcn)%% Description%% NET_STRUCT_SNN takes% Sl - Number of units in the l'th layer, for L layers.% TFl - Transfer function for the l'th layer. % trainFcn - The network training function (default TRAINLM_SNN).% costFcn - The cost fucntion which is minimized in training% (default WCF_SNN). % and returns a net_struct that can be used by TRAIN_SNN.%% In the SNN Feed Forward Neural Network toolbox, all parameters% regarding the network are stored in a net_struct containing the% following fields:%% net_struct.numLayers - number of layers in the network (L)% net_sturct.transferFcn - 1 x L cell matrix of transfer function names. % net_struct.biases - 1 x L cell matrix of N(l-1) x 1 matrices of% unit biases.% net_struct.weights - 1 x L cell matrix of N(l-1) x Nl matrices of % connection weights.% net_struct.trainFcn - trainfcn_struct with trainings% algorithm related parameters.% net_struct.costFcn - costfcn_struct with cost function% related parameters.% (L = number of layers, Nl = number of units in l'th layer)%% Example%% net = net_struct_snn([11 5 6], {'tansigtf_snn' 'lintf_snn'}, 'trainlm_snn');%% See also%% TRAIN_SNN, TRANSFERFCN_SNN, TRAINFCN_SNN, COSTFCN_SNN,% TRAINFCN_STRUCT_SNN, COSTFCN_STRUCT_SNN%if (nargin < 4) costFcn = 'wcf_snn'; endif (nargin < 3) trainFcn = 'trainlm_snn';endnet.numLayers = size(s,2) - 1;if (size(tf,2) ~= net.numLayers) error('TF and S must be equal is size');endnet.transferFcn = tf;for i = 1:net.numLayers net.biases{i} = 0.1*randn(s(1,i+1),1); net.weights{i} = 0.1*randn(s(1,i+1), s(1,i)); end%#function traingd_snn traincgp_snn trainlm_snnnet.trainFcn = feval(trainFcn, 'pdefaults');%#function wcf_snnnet.costFcn = feval(costFcn, 'pdefaults');
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -