how to compress a variable size matrix into a fixed size one?
3 views (last 30 days)
Show older comments
i need a function to convert variable size matrices into a fixed size of 25*25.
0 Comments
Answers (2)
ES
on 26 Sep 2013
You want to truncate first 25 rows and columns?
[m,n]=size(VariableSizeMatrix)
if (m>=25 && n>=25)
FixedSizeMatrix=VariableSizeMatrix(1:25,1:25)
end
if the size of VariableSizeMatrix is less than (25, 25) pad zeros or process according to your needs.
0 Comments
Jan
on 26 Sep 2013
It depends on what kind of compression you want. It could be cutting out a part on the top or bottom, right, left or from the center. You could mean a linear or cubic interpolation, or a Lanzcos resampling using imresize.
5 Comments
Walter Roberson
on 27 Sep 2013
You cannot fit all unique 1*700 vectors into 25*25 without data loss, but if there are at least 75 duplicates you could do it.
What you probably want is something like to extract "features" from the sentences, in such a way that the 700 different sentences reduced down to a 25*25 matrix, with the mapping being by some kind of "essential similarity", with the NN so produced able to classify other sentences according to their essential similarities.
For example, if you were to classify each word independently by the possible parts of speech the word could be, then instead of the actual words, you could record the allowed parts of speech in sequence, and train the NN on those sequences. The resulting training should be able to predict what the actual parts of speech were for each word, because the same patterns occur repeatedly. You might find, for example, that ADJECTIVE-NOUN-NOUN seldom occurs, and so could deduce that the ADJECTIVE-(NOUN or ADJECTIVE)-NOUN pattern "big red box" is likely the ADJECTIVE-ADJECTIVE-NOUN pattern that occurs more often. Such as in the pattern "big heavy box".
See Also
Categories
Find more on Matrix Indexing 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!