Unrolling a 20x20 grid of pixels into a 400 dimensional vector.
5 views (last 30 days)
Show older comments
During an exercise of a machine learning course, the task was to use logistic regression and neural networks to recognize handwirtten digits. For this, we are given a dataset containing 5000 training examples of handwritten digits where each example is a 20 x 20 pixel grayscale image of the digit. (I am not looking the answer on to how to do it)
When loading the data, it loads a 5000x400 matrix X where every row is a training example.
I would like to know how they have "unrolled" (as they call it) the 20x20 grid of pixels into a 400-dimensional vector and created this 5000x400 matrix X.
Thank you for yout help!
0 Comments
Answers (1)
Jan
on 12 Jan 2021
If the data are a collection of 500 matrices of the size 20x20:
data = rand(5000, 20, 20)
You can create the 2D matrix by:
data2D = reshape(data, 5000, 400)
0 Comments
See Also
Categories
Find more on Image Data Workflows 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!