how is output in time-delay neural network calculated with known weights and biases?
Mostrar comentarios más antiguos
Hi,
I am learning about neural networks that could be used to model time series and trying to manually calculate 1-step prediction of time series with known weights and biases.
Here is the code:
y = laser_dataset;
y = y(1:30); % use only 30 data points for simplicity
[y, ps] = mapminmax(cell2mat(y),-1,1); % normalize data and deal with normalized data only for simplicity
% y = [ 0.0720, 0.9520, 0.2160, 0.6480, -0.9520, 0.9680, -0.7920, -0.1520, 0.9040, 0.4720, -0.5360, -0.9360, -1, ...;]
nn = timedelaynet([1:8], 5); % delay of 8, 5 hidden neurons
nn.trainParam.epochs = 1000;
nn.divideFcn = '';
nn.inputs{1}.processFcns = {}; % no need to normalize
nn.outputs{2}.processFcns = {};
[xs,xi,ai,ts] = preparets(nn, num2cell(y), num2cell(y));
nn = train(nn, xs, ts, xi, ai);
yp = nn(xs, xi);
% yp = [ 0.9040, 0.4720, -0.5360, -0.9360, -1, ...;]
input = transpose(cell2mat(xi));
w1 = cell2mat(nn.IW(1,1)); % weights from input to layer 1 (hidden)
b1 = cell2mat(nn.b(1,1)); % bias weights at layer 1
a1 = tansig(w1*input+b1); % transfer function to hidden layer is tansig
% dimension check: w1 = [5x8] 8 connections to each of 5 neurons
% input = [8x1] from delay?, b1 = [5x1] 5 neurons with 1 bias each
% [5x8]*[8x1]+[5x1] = [5x1] hidden layer 5 neurons
w2 = cell2mat(nn.LW(2,1)); % weights from hidden layer to output layer
b2 = cell2mat(nn.b(2,1)); % bias weight at output layer
a2 = w2*a1+b2; % transfer function to output is linear
% dimension check: w2 = [1x5] 1 connection from each hidden neuron to output
% node, a1 = [5x1] 5 inputs from 5 hidden layer neurons
% b2 = [1x1] 1 bias at output node
% [1x5]*[5x1]+[1x1] = [1x1] output layer, 1 node
% a2 = -0.6409 but should not it be 0.9040 ?
Obviously I am not getting the 9th step value of 0.9040 which I should with this network (yp(1,1) = 0.9040).
My guess is I am not using the right input, I don't understand what the input would be with a delay. So far I used the 8 step delay, honestly because dimensions work out well with matrix multiplication.
Could somebody please help me?
Victoria
Respuestas (0)
Categorías
Más información sobre Deep Learning Toolbox en Centro de ayuda y File Exchange.
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!