A grayscale image represents visual content with intensity values in one channel rather than separate red, green, and blue channels. A 28 × 28 image therefore contains 784 pixel values, making it a compact target for classification and generation. Grayscale clothing images support tasks such as recognizing coats, bags, sneakers, and shirts, while handwritten grayscale digits support autoencoder training. section 2.0 section 2.2.2 section 7.2.1
Working with grayscale images typically involves these steps:
- Convert pixel integers from 0–255 into PyTorch floating-point tensors from 0.0 to 1.0 with ToTensor(). section 2.2.2
- Normalize the single channel, often with mean 0.5 and standard deviation 0.5, producing values from –1 to 1 for more efficient gradient descent. section 2.2.2
- Flatten or reshape the 784 values as required: classifiers and dense GANs can use vectors, while visualization restores the 28 × 28 layout. section 4.1.2 section 2.2.2
- Use convolutional networks when moving beyond simple grayscale generation toward high-resolution color images. section 4.6
Generating a 28 × 28 clothing image
A GAN generator can begin with a 100-value random noise vector and pass it through reversed dense layers to produce 784 values. Reshaping the result gives a 28 × 28 grayscale clothing image. With Tanh activation, the generated values lie between –1 and 1, matching normalized training data. section 4.1.2


