Complete the code to create a random noise vector for image generation.
noise = tf.random.normal(shape=([1], 100))
The batch size for generating images is commonly set to 64 for training stability.
Complete the code to define the output layer of a generator model for 28x28 grayscale images.
model.add(tf.keras.layers.Dense(28 * 28 * 1, activation=[1]))
The 'sigmoid' activation outputs values between 0 and 1, suitable for grayscale pixel intensities.
Fix the error in the code to reshape the generator output to image dimensions.
output_image = tf.reshape(generated_vector, ([1], 28, 28, 1))
The batch size must match the number of generated samples, here 64.
Fill both blanks to complete the discriminator model's output layer for binary classification.
model.add(tf.keras.layers.Dense(1, activation=[1])) model.compile(optimizer='adam', loss=[2], metrics=['accuracy'])
The discriminator outputs a probability with 'sigmoid' activation and uses 'binary_crossentropy' loss for two classes: real or fake.
Fill all three blanks to create a dictionary comprehension that maps generated images to labels 1 (real) or 0 (fake) based on a condition.
labels = {img: [1] for img in images if img.shape[0] [2] 28 and img.shape[1] [3] 28}Images with shape 28x28 are labeled 0 (fake). The conditions check if height and width equal 28.
