【发布时间】:2017-01-07 08:53:54
【问题描述】:
MATLAB 不允许在神经网络工具箱中使用多于一种类型的传递函数的层。所以,我想创建 2 个隐藏层,一个具有双曲正切传递函数,另一个具有 rbf 神经元。
但我需要将第一个隐藏层的输出直接传递给输出层。我正在考虑更改第二个隐藏层的输出,使其等于第一个隐藏层的输出。为此,我需要访问隐藏层的输出值。
我已经打开了traingd 函数,我想我想要的是这段代码的某些部分:
for epoch=0:param.epochs
% Stopping Criteria
if isMainWorker
current_time = etime(clock,startTime);
[userStop,userCancel] = nntraintool('check');
if userStop, tr.stop = 'User stop.'; calcNet = best.net;
elseif userCancel, tr.stop = 'User cancel.'; calcNet = original_net;
elseif (perf <= param.goal), tr.stop = 'Performance goal met.'; calcNet = best.net;
elseif (epoch == param.epochs), tr.stop = 'Maximum epoch reached.'; calcNet = best.net;
elseif (current_time >= param.time), tr.stop = 'Maximum time elapsed.'; calcNet = best.net;
elseif (gradient <= param.min_grad), tr.stop = 'Minimum gradient reached.'; calcNet = best.net;
elseif (val_fail >= param.max_fail), tr.stop = 'Validation stop.'; calcNet = best.net;
end
% Training record & feedback
tr = nntraining.tr_update(tr,[epoch current_time perf vperf tperf gradient val_fail]);
statusValues = [epoch,current_time,best.perf,gradient,val_fail];
nn_train_feedback('update',archNet,rawData,calcLib,calcNet,tr,status,statusValues);
stop = ~isempty(tr.stop);
end
% Stop
if isParallel, stop = labBroadcast(mainWorkerInd,stop); end
if stop, return, end
% Gradient Descent
if isMainWorker
dWB = param.lr * gWB;
WB = WB + dWB;
end
calcNet = calcLib.setwb(calcNet,WB);
[perf,vperf,tperf,gWB,gradient] = calcLib.perfsGrad(calcNet);
% Validation
if isMainWorker
[best,tr,val_fail] = nntraining.validation(best,tr,val_fail,calcNet,perf,vperf,epoch);
end
end
我找到了偏差和突触的更新位置,但我无法找到神经元输出值的设置位置。有人可以帮我吗?
【问题讨论】:
标签: matlab neural-network