Borrar filtros
Borrar filtros

Info

La pregunta está cerrada. Vuélvala a abrir para editarla o responderla.

How to compute an ANN ouptut manually knowing the ANN weights and biases?

1 visualización (últimos 30 días)
Ahmed Elkady
Ahmed Elkady el 4 de Feb. de 2023
Cerrada: Ahmed Elkady el 8 de Feb. de 2023
I got a trained simple neural network named "net" with 12 input values, a single hidden layer with 9 nuerons, and single numeric output.
To get predicitons,
1) I used the trained "net" object as follows:
y = net(input)
2) I then tried to re-use the network manually as follows:
% Extract network weights and biases
w1 = net.IW{1}; %the input-to-hidden layer weights
w2 = net.LW{2}; %the hidden-to-output layer weights
b1 = net.b{1}; %the input-to-hidden layer bias
b2 = net.b{2}; %the hidden-to-output layer bias
% Check the activaition function type in the hidden and output layers
net.layers{1}.transferFcn % = tansig
net.layers{2}.transferFcn % = purelin
% Compute precition with a feed-forward pass through the net
L1_vals = tansig((wL1*input)+b1); % Layer #1 node values
y = purelin(wL2*L1_vals + b2); % Output node value (prediction)
The first option provides the correct predcition but the second "manual" option does not.
Did I miss anything in the manual computation?
Here are the complete network properites for reference:
net =
Neural Network
name: 'Feed-Forward Neural Network'
userdata: (your custom info)
dimensions:
numInputs: 1
numLayers: 2
numOutputs: 1
numInputDelays: 0
numLayerDelays: 0
numFeedbackDelays: 0
numWeightElements: 127
sampleTime: 1
connections:
biasConnect: [1; 1]
inputConnect: [1; 0]
layerConnect: [0 0; 1 0]
outputConnect: [0 1]
subobjects:
input: Equivalent to inputs{1}
output: Equivalent to outputs{2}
inputs: {1x1 cell array of 1 input}
layers: {2x1 cell array of 2 layers}
outputs: {1x2 cell array of 1 output}
biases: {2x1 cell array of 2 biases}
inputWeights: {2x1 cell array of 1 weight}
layerWeights: {2x2 cell array of 1 weight}
functions:
adaptFcn: 'adaptwb'
adaptParam: (none)
derivFcn: 'defaultderiv'
divideFcn: 'divideind'
divideParam: .trainInd, .valInd, .testInd
divideMode: 'sample'
initFcn: 'initlay'
performFcn: 'mse'
performParam: .regularization, .normalization
plotFcns: {'plotperform', plottrainstate, ploterrhist,
plotregression}
plotParams: {1x4 cell array of 4 params}
trainFcn: 'trainlm'
trainParam: .showWindow, .showCommandLine, .show, .epochs,
.time, .goal, .min_grad, .max_fail, .mu, .mu_dec,
.mu_inc, .mu_max
weight and bias values:
IW: {2x1 cell} containing 1 input weight matrix
LW: {2x2 cell} containing 1 layer weight matrix
b: {2x1 cell} containing 2 bias vectors

Respuestas (0)

La pregunta está cerrada.

Productos


Versión

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by