The full code is available here — DCGAN Tutorial — PyTorch Tutorials 1.9.0+cu102 documentation 2
What is a proper way to modify the code above to adjust the model for a dataset that consists of black and white/grayscale images, not RGB?
This model is designed for processing 3-channel images (RGB) while I need to handle some black and white image data, so I’d like to change the “ch” parameter to “1” instead of “3.”
But if we just change this parameter — “nc = 3” → “nc = 1” — without adjusting generator’s and discriminator’s code blocks, executing just gives an error message:
RuntimeError: Given groups=1, weight of size [64, 1, 4, 4], expected input[128, 3, 64, 64] to have 1 channels, but got 3 channels instead

Please advise.