Пример #1
0
 def test_build_graph(self, gan_type):
     if tf.executing_eagerly():
         # `tfgan.gan_model` doesn't work when executing eagerly.
         return
     hparams = self.hparams._replace(max_number_of_steps=0,
                                     gan_type=gan_type)
     train_lib.train(hparams)
Пример #2
0
    def test_build_graph(self, gan_type, mock_data_provider):
        hparams = self.hparams._replace(max_number_of_steps=0,
                                        gan_type=gan_type)

        # Mock input pipeline.
        mock_imgs = np.zeros([hparams.batch_size, 28, 28, 1], dtype=np.float32)
        mock_lbls = np.concatenate(
            (np.ones([hparams.batch_size, 1], dtype=np.int32),
             np.zeros([hparams.batch_size, 9], dtype=np.int32)),
            axis=1)
        mock_data_provider.provide_data.return_value = (mock_imgs, mock_lbls)

        train_lib.train(hparams)
Пример #3
0
    def test_run_one_train_step(self, mock_data_provider):
        hparams = self.hparams._replace(max_number_of_steps=1,
                                        gan_type='unconditional',
                                        batch_size=5,
                                        grid_size=1)
        tf.compat.v1.set_random_seed(1234)

        # Mock input pipeline.
        mock_imgs = np.zeros([hparams.batch_size, 28, 28, 1], dtype=np.float32)
        mock_lbls = np.concatenate(
            (np.ones([hparams.batch_size, 1], dtype=np.int32),
             np.zeros([hparams.batch_size, 9], dtype=np.int32)),
            axis=1)
        mock_data_provider.provide_data.return_value = (mock_imgs, mock_lbls)

        train_lib.train(hparams)
Пример #4
0
    def test_build_graph(self, gan_type, mock_data_provider):
        if tf.executing_eagerly():
            # `tfgan.gan_model` doesn't work when executing eagerly.
            return
        hparams = self.hparams._replace(max_number_of_steps=0,
                                        gan_type=gan_type)

        # Mock input pipeline.
        mock_imgs = np.zeros([hparams.batch_size, 28, 28, 1], dtype=np.float32)
        mock_lbls = np.concatenate(
            (np.ones([hparams.batch_size, 1], dtype=np.int32),
             np.zeros([hparams.batch_size, 9], dtype=np.int32)),
            axis=1)
        mock_data_provider.provide_data.return_value = (mock_imgs, mock_lbls)

        train_lib.train(hparams)
Пример #5
0
def main(_):
    hparams = train_lib.HParams(FLAGS.batch_size, FLAGS.train_log_dir,
                                FLAGS.max_number_of_steps, FLAGS.gan_type,
                                FLAGS.grid_size, FLAGS.noise_dims)
    train_lib.train(hparams)
Пример #6
0
 def test_run_one_train_step(self):
     if tf.executing_eagerly():
         # `tfgan.gan_model` doesn't work when executing eagerly.
         return
     train_lib.train(self.hparams)