how to compress a variable size matrix into a fixed size one?
古いコメントを表示
i need a function to convert variable size matrices into a fixed size of 25*25.
回答 (2 件)
ES
2013 年 9 月 26 日
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.
Jan
2013 年 9 月 26 日
0 投票
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 件のコメント
Vidhya Dharshini
2013 年 9 月 26 日
Jan
2013 年 9 月 26 日
@Vidhya: The question is not clear yet. What kind of result do you expect for a scalar, a [1 x 2] vector, a [2 x 1] vector, a [2x2] matrix and a [1 x 700] vectors, whose elements will not fit into a 25*25 matrix?
We cannot guess these details based on the fact, that you want to feed a NN with it.
Vidhya Dharshini
2013 年 9 月 27 日
Walter Roberson
2013 年 9 月 27 日
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".
Vidhya Dharshini
2013 年 9 月 27 日
カテゴリ
ヘルプ センター および File Exchange で Logical についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!