MATLAB在神经网络工具箱中不允许具有多于一种类型的传递函数的一层。所以,我想创建2个隐藏层,一个带有双曲正切传递函数,另一个带有rbf神经元。如何访问MATLAB中隐藏层神经元的输出值?
但我需要直接为输出图层传递第一个隐藏层的输出。我正在考虑改变第二个隐藏层的输出,以便它变得等于第一个隐藏层的输出。为此,我需要访问隐藏层输出的值。 我已经打开了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
我发现那里的偏见和突触被更新,但我没能找到的地方神经元输出值被设置。有人能帮助我吗?
谢谢!真的,我没有那样做过。但你的答案是有用的。在这篇文档中,关于如何选择哪些图层相互连接以及哪些图层与输入和输出连接起来进行了扩展。 –