def test_define_train_ops(self, mock_summary_scalar): FLAGS.batch_size = 2 FLAGS.generator_lr = 0.1 FLAGS.discriminator_lr = 0.01 images_shape = [FLAGS.batch_size, 4, 4, 3] images_x = tf.zeros(images_shape, dtype=tf.float32) images_y = tf.zeros(images_shape, dtype=tf.float32) cyclegan_model = train._define_model(images_x, images_y) cyclegan_loss = tfgan.cyclegan_loss(cyclegan_model, cycle_consistency_loss_weight=10.0) train_ops = train._define_train_ops(cyclegan_model, cyclegan_loss) self.assertIsInstance(train_ops, tfgan.GANTrainOps) mock_summary_scalar.assert_has_calls([ mock.call('generator_lr', mock.ANY), mock.call('discriminator_lr', mock.ANY) ])
def test_define_train_ops(self, mock_summary_scalar): FLAGS.batch_size = 2 FLAGS.generator_lr = 0.1 FLAGS.discriminator_lr = 0.01 images_shape = [FLAGS.batch_size, 4, 4, 3] images_x = tf.zeros(images_shape, dtype=tf.float32) images_y = tf.zeros(images_shape, dtype=tf.float32) cyclegan_model = train._define_model(images_x, images_y) cyclegan_loss = tfgan.cyclegan_loss( cyclegan_model, cycle_consistency_loss_weight=10.0) train_ops = train._define_train_ops(cyclegan_model, cyclegan_loss) self.assertIsInstance(train_ops, tfgan.GANTrainOps) mock_summary_scalar.assert_has_calls([ mock.call('generator_lr', mock.ANY), mock.call('discriminator_lr', mock.ANY) ])
def test_define_train_ops(self, mock_summary_scalar): FLAGS.batch_size = 2 FLAGS.generator_lr = 0.1 FLAGS.discriminator_lr = 0.01 images_shape = [FLAGS.batch_size, 4, 4, 3] images = tf.zeros(images_shape, dtype=tf.float32) labels = tf.one_hot([0] * FLAGS.batch_size, 2) model = train._define_model(images, labels) loss = tfgan.stargan_loss(model) train_ops = train._define_train_ops(model, loss) self.assertIsInstance(train_ops, tfgan.GANTrainOps) mock_summary_scalar.assert_has_calls([ mock.call('generator_lr', mock.ANY), mock.call('discriminator_lr', mock.ANY) ])