MATLAB Answers

neural network input target data format, Vertical or Horizontal vector within cell array?

9 views (last 30 days)
Emil
Emil on 15 Feb 2013
I have a set of vectors measured dx dy on a given set of coordinates over a time period i=1:5;
If I make two neural networks, one for x and one for y, does my input for “error” and “input” (see below example code) have to be vertical or horizontal vector within the cell array?
%%%%%%%%%
example code
%%%%%%%%%
% if I have a set of vertical vectors coordinates with X position defined by Column 1 = cord(:,1) and Y position defines by Column 2 = (cord(:,2))
cord=[-2 -2;-2 -1;-2 0;-2 1;-2 2;-1 -2;-1 -1;-1 0;-1 1;-1 2;0 -2;0 -1;0 0;0 1;0 2; 1 -2;1 -1;1 0;1 1;1 2;2 -2;2 -1;2 0;2 1;2 2];
% I have a set of target vectors per point defined by dx = tmpError(:,1) & dy = tmpError(:,2)
tmpError=[0.3 0.2;0.1 0.2;0.3 0.4;0.1 0.2;0.4 0.5;...
0.1 0.4;0.2 0.1;0.3 0.2;0.1 0.2;0.4 0.5;...
0.2 0.2;0.4 0.4;0.2 0.1;0.3 0.2;0.1 0.5;...
0.4 0.3;0.3 0.3;0.3 0.2;0.2 0.2;0.3 0.5;...
0.3 0.2;0.4 0.2;0.1 0.4;0.4 0.2;0.4 0.5];
for i=1:5
error{i}=tmpError*i;
errorDx{i}=tmpError*i;
errorDy{i}=tmpError*i;
end
% Input would be same dxInput = input(:,1) & dyInput = input(:,2)
tmpInput=[1.3 1.2;1.1 1.2;1.3 1.4;1.1 1.2;1.4 1.5; 2.1 2.4;2.2 2.1;2.3 2.2;2.1 2.2;2.4 2.5; 3.2 3.2;3.4 3.4;3.2 3.1;3.3 3.2;3.1 3.5; 4.4 4.3;4.3 4.3;4.3 4.2;4.2 4.2;4.3 4.5; 5.3 5.2;5.4 5.2;5.1 5.4;5.4 5.2;5.4 5.5];
for i=1:5
input{i}=tmpInput*i;
inputDx{i}=tmpInput(:,1)*i;
inputDy{i}=tmpInput(:,2)*i;
end
%% OR should they be transposed....
cord=cord';
tmpError=tmpError';
for i=1:5
error{i}=tmpError*i;
errorDx{i}=tmpError(1,:)*i;
errorDy{i}=tmpError(2,:)*i;
end
tmpInputDx=repmat(tmpInput(:,1),1,5);
tmpInputDy=repmat(tmpInput(:,2),1,5);
  2 Comments
Emil
Emil on 16 Feb 2013
Thanks for your reply.
I fixed the original code (i hope) ... See code in original message.

Sign in to comment.

Answers (2)

DemoiselX
DemoiselX on 15 Feb 2013
Edited: DemoiselX on 15 Feb 2013
hi, can you explain more your problem ?
  1 Comment
Emil
Emil on 15 Feb 2013
Sure.. sorry for not coming across clear enough.
If I use cell array as my input and target a Neural Net Time Series, I understand that the input & target can be single column (within a row of a cell array) per point in time or a single row with multiple columns. If all inputs effect traget postions equally I would think it would be ok to enter them as a single column. It not the same could be done by transposing my original vector an repmat
as well, just realized my example code should looks something like this for the transposed input....
tmpInputDx=repmat(tmpInput(:,1),1,5)

Sign in to comment.


Greg Heath
Greg Heath on 15 Feb 2013
It would be helpful to the reader (especially the older ones) if you would use the notation 0.69 instead of just .69.
All inputs and outputs to the NN functions are matrices or cells of column vectors.
For a data set of N I-dimensional input vectors and N corresponding O-dimensional target vectors
[ I N ] = size(input)
[ O N ] = size(target)
or the cell equivalents
Inputs = { inputs };
Targets = { targets };
Hope this helps.
Thank you for formally accepting my answer
Greg
  3 Comments
Greg Heath
Greg Heath on 16 Feb 2013
In the general case, they are columns. You may be getting fooled by looking at one-dimensional timeseries. Each measurement is a one-dimensional column vector. The fact that you see the total data as a row instead of a sequence of one-dimensional columns is irrelevant.
Hope this helps.
Greg

Sign in to comment.

Community Treasure Hunt

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

Start Hunting!