Unrolling a 20x20 grid of pixels into a 400 dimensional vector.
5 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
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 comentarios
Respuestas (1)
Jan
el 12 de En. de 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 comentarios
Ver también
Categorías
Más información sobre Image Data Workflows en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!