how to find output of hidden layers in neural networks?

4 ビュー (過去 30 日間)
Sujay Pandey
Sujay Pandey 2017 年 9 月 14 日
編集済み: KSSV 2017 年 9 月 14 日
I am trying to find out the output of neural network in the following code :-
clear;
% Solve an Input-Output Fitting problem with a Neural Network
% Script generated by NFTOOL
%
% This script assumes these variables are defined:
%
% houseInputs - input data.
% houseTargets - target data.
% load bodyfat_dataset
%inputs = bodyfatInputs;
%targets = bodyfatTargets;
%[inputs, targets] = bodyfat_dataset;
inputs = [0,1,0,1;0,0,1,1];
targets = [0 0 0 1;0 1 0 1];
% Create a Fitting Network
hiddenLayerSize = [10];
net = fitnet(hiddenLayerSize);
% Set up Division of Data for Training, Validation, Testing
net.divideParam.trainRatio = 100/100;
net.divideParam.valRatio = 15/100;
net.divideParam.testRatio = 15/100;
% mynet = feedforwardnet % Just a toy example, without any training
weights = net.LW;
biases = net.b;
%netname = net.layers{2}.size;
% Train the Network
[net,tr] = train(net,inputs,targets);
net1 = network;
%net1.numLayers =1;
net1.numInputs = 2;
%net1.numOutputs = 10;
net1.numLayers = 2;
% net1.IW=net.IW;
%net1.layerWeights{1,1} = net.layerWeights{1,1};
view(net1);
% Test the Network
outputs = net(inputs);
errors = gsubtract(outputs,targets);
performance = perform(net,targets,outputs)
% View the Network
view(net)
weights = net.LW
biases = net.b
IW = (net.IW{1,1});
b1 = net.b{1,1};
mult = IW * [-1;-1];
h = tansig( mult + b1 );
b2 = net.b{2,1};
IW1 = weights{2,1};
mult1 = IW1 * h;
h1 = purelin( mult1 + b2 )
h1 here is coming out to be completely different from the actual output :( please help!
  1 件のコメント
Greg Heath
Greg Heath 2017 年 9 月 14 日
Please format and eliminate statements that are not necessary.
Greg

サインインしてコメントする。

回答 (0 件)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by