Unrolling a 20x20 grid of pixels into a 400 dimensional vector.
조회 수: 4 (최근 30일)
이전 댓글 표시
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
답변 (1개)
Jan
2021년 1월 12일
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
참고 항목
카테고리
Help Center 및 File Exchange에서 Image Data Workflows에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!