how calculate neural network output
Show older comments
how i can calculate output in neural time series tool(ntstool)
nonlinear input-output
input=1
output=10
thanks
function [y1,xf1] = myNeuralNetworkFunction(x1,xi1) MYNEURALNETWORKFUNCTION neural network simulation function.
Generated by Neural Network Toolbox function genFunction, 22-May-2016 23:18:57.
[y1,xf1] = myNeuralNetworkFunction(x1,xi1) takes these arguments:
x1 = 1xTS matrix, input #1
xi1 = 1x1 matrix, initial 1 delay states for input #1.
and returns:
y1 = 1xTS matrix, output #1
xf1 = 1x1 matrix, final 1 delay states for input #1.
where TS is the number of timesteps.
===== NEURAL NETWORK CONSTANTS =====
Input 1
x1_step1.xoffset = 1;
x1_step1.gain = 0.0135135135135135;
x1_step1.ymin = -1;
Layer 1
b1 = 5.764645687414239e-05;
IW1_1 = -0.027545572380755706;
Layer 2
b2 = 0.0089098996302408792;
LW2_1 = -36.556093898765383;
Output 1
y1_step1.ymin = -1;
y1_step1.gain = 0.00272108843537415;
y1_step1.xoffset = 10;
===== SIMULATION ========
Dimensions
TS = size(x1,2); timesteps
Input 1 Delay States
xd1 = mapminmax_apply(xi1,x1_step1);
xd1 = [xd1 zeros(1,1)];
Allocate Outputs
y1 = zeros(1,TS);
Time loop
for ts=1:TS
Rotating delay state position
xdts = mod(ts+0,2)+1;
Input 1
xd1(:,xdts) = mapminmax_apply(x1(:,ts),x1_step1);
Layer 1
tapdelay1 = reshape(xd1(:,mod(xdts-1-1,2)+1),1,1);
a1 = tansig_apply(b1 + IW1_1*tapdelay1);
Layer 2
a2 = b2 + LW2_1*a1;
Output 1
y1(:,ts) = mapminmax_reverse(a2,y1_step1);
end
Final delay states
finalxts = TS+(1: 1);
xits = finalxts(finalxts<=1);
xts = finalxts(finalxts>1)-1;
xf1 = [xi1(:,xits) x1(:,xts)];
end
===== MODULE FUNCTIONS ========
Map Minimum and Maximum Input Processing Function
function y = mapminmax_apply(x,settings)
y = bsxfun(@minus,x,settings.xoffset);
y = bsxfun(@times,y,settings.gain);
y = bsxfun(@plus,y,settings.ymin);
end
Sigmoid Symmetric Transfer Function
function a = tansig_apply(n,~)
a = 2 ./ (1 + exp(-2*n)) - 1;
end
Map Minimum and Maximum Output Reverse-Processing Function
function x = mapminmax_reverse(y,settings)
x = bsxfun(@minus,y,settings.ymin);
x = bsxfun(@rdivide,x,settings.gain);
x = bsxfun(@plus,x,settings.xoffset);
end
Answers (1)
Ahmet Engin ADIYAMAN
on 29 May 2022
0 votes
Exactly what I am looking for, unanswered for 6 years...
Categories
Find more on Sources and Sinks in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!