Exemple #1
0
                     feed_dict={
                         isTraining: True,
                         batchSizeTensor: batchSize
                     })
            sess.run(G_optimizer,
                     feed_dict={
                         isTraining: True,
                         batchSizeTensor: batchSize
                     })

            # Save summary
            '''if globalStep % 20 == 0:
				summary = sess.run(merged_summ, feed_dict={ isTraining: True, batchSizeTensor : batchSize })
				summary_writer.add_summary(summary, globalStep)'''

            # Save checkpoints and images
            if globalStep % 100 == 0:
                save_path = saver.save(
                    sess, base_path + "checkpoints/model-" + str(globalStep) +
                    ".ckpt")
                G_output = sess.run(G_z,
                                    feed_dict={
                                        isTraining: False,
                                        batchSizeTensor: 5
                                    })
                util.saveImages(base_path + "images/out-" + str(globalStep),
                                G_output)

            globalStep += 1
    except tf.errors.OutOfRangeError:
        pass
Exemple #2
0
            noise = util.sample_noise([batchSize, Z_dim])

            # Train discriminator (more at the beginning)
            D_iterations = 30 if (GStep < 5 or GStep % 500 == 0) else num_D
            for _ in range(D_iterations):
                _, summary = sess.run([D_optimizer, merged_summary],
                                      feed_dict={
                                          isTraining: True,
                                          Z: noise
                                      })
                summary_writer.add_summary(summary, GStep)

            # Train Generator
            sess.run(G_optimizer, feed_dict={isTraining: True, Z: noise})

            # Save checkpoint and generated images at this step
            if GStep % 1000 == 0:
                saver.save(
                    sess,
                    basePath + "checkpoints/ckpt-ResWDCGAN-" + str(GStep))
                output = sess.run(G_z,
                                  feed_dict={
                                      isTraining: False,
                                      Z: util.sample_noise([10, Z_dim])
                                  })
                util.saveImages(
                    basePath + "images/out-ResWDCGAN-" + str(GStep), output)
            GStep += 1
    except tf.errors.OutOfRangeError:
        pass
Exemple #3
0
    AEStep = 0
    sess.run(iterator.initializer)
    try:
        while True:
            noise = util.sample_noise([batchSize, Z_dim])

            # Train Critic
            _, summary = sess.run([C_optimizer, AE_merged_summary],
                                  feed_dict={
                                      isTraining: True,
                                      Z: noise
                                  })
            AE_summary_writer.add_summary(summary, AEStep)

            # Train AE only
            sess.run(AE_optimizer, feed_dict={isTraining: True, Z: noise})

            if AEStep % 750 == 0:
                saver.save(sess,
                           basePath + "checkpoints/ckpt-AE-" + str(AEStep))
                AE_output = sess.run(G_AE,
                                     feed_dict={
                                         isTraining: False,
                                         Z: util.sample_noise([4, Z_dim])
                                     })
                util.saveImages(basePath + "images/out-AE-" + str(AEStep),
                                AE_output)
            AEStep += 1
    except tf.errors.OutOfRangeError:
        pass
Exemple #4
0
Z = tf.placeholder(tf.float32, [None, Z_dim])
isTraining = tf.placeholder(dtype=tf.bool)

G_z = network.generator(Z, isTraining)
G_AE, _ = UNET_GAN.getAutoencoder(G_z, isTraining)

with tf.Session() as sess:
    saver = tf.train.Saver()
    sess.run(tf.global_variables_initializer())

    saver.restore(sess, basePath + "checkpoints/ckpt-AE-101250")
    #saver.restore(sess, basePath + "checkpoints-mel/ckpt-AE-88500")

    images, fullImg = [], []
    for j in range(50):
        UNET_output, G_output = sess.run([G_AE, G_z],
                                         feed_dict={
                                             isTraining: False,
                                             Z: util.sample_noise([1, Z_dim])
                                         })
        images.append(G_output[0])
        fullImg.append(UNET_output[0])

    images = np.array(images)
    fullImg = np.array(fullImg)
    print(images.shape)
    print(fullImg.shape)

    util.saveImages(basePath + "generated/TEST-" + str(0), images)
    util.saveImages(basePath + "generated/TEST-AE-" + str(0), fullImg)