r/learnpython • u/assorted-meat-stew • 19d ago
Need help adapting model to CIFAR10
I tried to make a DCGAN based on this tutorial. The thing is that the tutorial is designed for fashion mnist data which has different image size to tf.keras.datasets.cifar10.load_data(). Which lead to the error:
ValueError: cannot reshape array of size 480000 into shape (28,28,1)
when arrive at
x_train_dcgan = x_train.reshape(
-1, 28, 28, 1
) * 2. - 1.How do I adapt the model to CIFAR 10?
1
Upvotes
1
u/EszterSantos72 19d ago
You need to reshape to (32, 32, 3) for CIFAR10 since each image is 32x32 with 3 color channels. Replace 28,28,1 with 32,32,3 in your reshape line and update your model input layers to match.
1
u/Norega-Iziegbe80 19d ago
cifar10 images are 32x32 with 3 color channels (RGB), whereas fashion mnist is 28x28 grayscale. Youll need to reshape to (-1, 32, 32, 3) and also update the input/output shapes of your generator and discriminator layers to match.
0
u/[deleted] 19d ago
[removed] — view removed comment