diff options
| -rw-r--r-- | cgan.py | 6 | ||||
| -rw-r--r-- | dcgan.py | 4 | ||||
| -rw-r--r-- | lenet.py | 2 | 
3 files changed, 6 insertions, 6 deletions
| @@ -113,7 +113,7 @@ class CGAN():          return Model([img, label], validity) -    def train(self, epochs, batch_size=128, sample_interval=50, graph=False): +    def train(self, epochs, batch_size=128, sample_interval=50, graph=False, smooth_real=1, smooth_fake=0):          # Load the dataset          (X_train, y_train), (_, _) = mnist.load_data() @@ -147,8 +147,8 @@ class CGAN():              gen_imgs = self.generator.predict([noise, labels])              # Train the discriminator -            d_loss_real = self.discriminator.train_on_batch([imgs, labels], valid) -            d_loss_fake = self.discriminator.train_on_batch([gen_imgs, labels], fake) +            d_loss_real = self.discriminator.train_on_batch([imgs, labels], valid*smooth_real) +            d_loss_fake = self.discriminator.train_on_batch([gen_imgs, labels], valid*smooth_fake)              d_loss = 0.5 * np.add(d_loss_real, d_loss_fake)              # --------------------- @@ -124,7 +124,7 @@ class DCGAN():          return Model(img, validity) -    def train(self, epochs, batch_size=128, save_interval=50): +    def train(self, epochs, batch_size=128, save_interval=50, VBN=False):          # Load the dataset          (X_train, _), (_, _) = mnist.load_data() @@ -139,6 +139,7 @@ class DCGAN():          xaxis = np.arange(epochs)          loss = np.zeros((2,epochs)) +          for epoch in tqdm(range(epochs)):              # --------------------- @@ -150,7 +151,6 @@ class DCGAN():              imgs = X_train[idx]              tf.keras.backend.get_session().run(tf.global_variables_initializer())  -              # Sample noise and generate a batch of new images              noise = np.random.normal(0, 1, (batch_size, self.latent_dim))              gen_imgs = self.generator.predict(noise) @@ -125,8 +125,8 @@ def test_classifier(model, x_test, y_true):    y_pred = model.predict(x_test)    y_pred = np.argmax(y_pred, axis=1)    y_true = np.argmax(y_true, axis=1) -  print("Test acc:", accuracy_score(y_true, y_pred))    plot_example_errors(y_pred, y_true, x_test) +  return accuracy_score(y_true, y_pred)  def mix_data(X_train, y_train, X_validation, y_validation, train_gen, tr_labels_gen, val_gen, val_labels_gen, split=0): | 
