2D array as input to neural network

My neural network has 2 feature variables each with a length of 112. Further I have 5 samples from each person and there are total 5 persons.
input= 2 rows, 112(per class feature vector length), 5 persons and 5 samples per person, so its (2, 112 x 5 x 5)
output = (5 (classes), 112 x 5 x 5)
I intend to specify the basic unit of classification as 2 x 112. Any idea how can I do this ? Currently its consider each column 2 x 1 as one input.

2 个评论

Did you experiment with transposing the input array to 112 x 2, just to see what would happen?
I guess in that case it will be 112 x 1 as each column will be treated as a feature vector of length 112. Kindly correct me if I am wrong.

请先登录,再进行评论。

 采纳的回答

Greg Heath
Greg Heath 2013-2-19
编辑:Greg Heath 2013-2-19
Burp...(coke, not coffee).
The input matrix must contain N I-dimensional column vectors
[ I N ] = size(input) % [ 224 25 }
The target matrix contains N O-dimensional column vectors
[ O N ] = size(output)% [ 5 25 ]
For c class classification, the N target vectors are columns of the c-dimensional unit matrix eyec = eye(c) with the row index of the "1" equal to the class index of the corresponding input column.
The target matrix can be formed from a class index row vector (and vice versa via the functions ind2vec and vec2ind. The column sum is an N-dimensional row vector of ones (ones(1,N)) and the row sum is the c-dimensional column vector (c*ones(c,1)).
I believe the training function of the obsolete newpr and current patternnet is 'trainscg' which uses batch training. The order of the vectors is arbitrary.
Hope this helps.
Thank you for formally accepting my answer
Greg
P.S. You should investigate reducing the dimensionaliy of the 224 dimensional input vectors.

更多回答(1 个)

Walter Roberson
Walter Roberson 2013-2-19
A feature cannot be a 2D array. You can reshape() to make each feature a column.

5 个评论

But the problem is that my input consists of vectors having magnitude and angle(direction). Currently I am feeding magnitude in one row and theta in the 2nd row. If I reshape the 2 x 112 as (2 x 112, 1), Then will it be OK to have magnitude, angle, magnitude, angle and so on interleaved form ? I mean this way the theta related to a specific magnitude may be lost.
Were you planning to try to process the different items in different ways? For example tansig the magnitude but not the direction? If not, then in theory having them interleaved should not matter, as neural networks are intended to form their own notion of the relationship between parts of features.
Thanks for your reply.
I am treating them in a similar fashion. So according to your last comment, interleaving doesn't matter. Is it possible to treat some elements of the feature vector in a different way than the other (in the same network) ?
I do not know if it is possible to treat different elements differently. Maybe with custom functions of some kind. Greg would know; he might visit the topic in anywhere between 4 hours and 4 days (depending on when he gets enough coffee in his system.)
It doesn't matter how your input rows are ordered.
However, I suggest transforming to cartesian coordinates so that
input = [ x ; y ]
with
size(y) = size(x) = [ 112 25 ]

请先登录,再进行评论。

Community Treasure Hunt

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

Start Hunting!

Translated by