Skip to content

Instantly share code, notes, and snippets.

EPOCHS = 50
BATCH_SIZE = 128
BATCH_BLOCKS = x_train.shape[0] // BATCH_SIZE
discriminator_losses = []
gan_losses = []
for epoch in range(EPOCHS):
for batch_index in range(BATCH_BLOCKS):
batch = x_train[batch_index * BATCH_SIZE:(batch_index + 1) * BATCH_SIZE].reshape(BATCH_SIZE, 784)
LATENT_SIZE = 16
adam = keras.optimizers.Adam(lr=0.0002, beta_1=0.5)
with tf.device("/gpu:0"):
input_x_img = keras.layers.Input((784,))
x = keras.layers.Dense(1024, activation="relu")(input_x_img)
x = keras.layers.Dense(256, activation="relu")(x)
x = keras.layers.Dense(1, activation="sigmoid")(x)
discriminator = keras.models.Model(inputs=input_x_img, outputs=x)
(x_train, y_train), (x_test, y_test) = mnist.load_data()
x_train = x_train / 256
y_train = y_train / 256
np.random.shuffle(x_train)
import tensorflow as tf
from tensorflow import keras
from tensorflow.keras.datasets import mnist
import numpy as np
from matplotlib import pyplot as plt