当前位置: 首页>>代码示例>>Python>>正文


Python dcgan.generator方法代码示例

本文整理汇总了Python中nets.dcgan.generator方法的典型用法代码示例。如果您正苦于以下问题:Python dcgan.generator方法的具体用法?Python dcgan.generator怎么用?Python dcgan.generator使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在nets.dcgan的用法示例。


在下文中一共展示了dcgan.generator方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_generator_graph

# 需要导入模块: from nets import dcgan [as 别名]
# 或者: from nets.dcgan import generator [as 别名]
def test_generator_graph(self):
    tf.set_random_seed(1234)
    # Check graph construction for a number of image size/depths and batch
    # sizes.
    for i, batch_size in zip(xrange(3, 7), xrange(3, 8)):
      tf.reset_default_graph()
      final_size = 2 ** i
      noise = tf.random_normal([batch_size, 64])
      image, end_points = dcgan.generator(
          noise,
          depth=32,
          final_size=final_size)

      self.assertAllEqual([batch_size, final_size, final_size, 3],
                          image.shape.as_list())

      expected_names = ['deconv%i' % j for j in xrange(1, i)] + ['logits']
      self.assertSetEqual(set(expected_names), set(end_points.keys()))

      # Check layer depths.
      for j in range(1, i):
        layer = end_points['deconv%i' % j]
        self.assertEqual(32 * 2**(i-j-1), layer.get_shape().as_list()[-1]) 
开发者ID:leimao,项目名称:DeepLab_v3,代码行数:25,代码来源:dcgan_test.py

示例2: test_generator_graph

# 需要导入模块: from nets import dcgan [as 别名]
# 或者: from nets.dcgan import generator [as 别名]
def test_generator_graph(self):
    tf.set_random_seed(1234)
    # Check graph construction for a number of image size/depths and batch
    # sizes.
    for i, batch_size in zip(xrange(3, 7), xrange(3, 8)):
      tf.reset_default_graph()
      final_size = 2 ** i
      noise = tf.random.normal([batch_size, 64])
      image, end_points = dcgan.generator(
          noise,
          depth=32,
          final_size=final_size)

      self.assertAllEqual([batch_size, final_size, final_size, 3],
                          image.shape.as_list())

      expected_names = ['deconv%i' % j for j in xrange(1, i)] + ['logits']
      self.assertSetEqual(set(expected_names), set(end_points.keys()))

      # Check layer depths.
      for j in range(1, i):
        layer = end_points['deconv%i' % j]
        self.assertEqual(32 * 2**(i-j-1), layer.get_shape().as_list()[-1]) 
开发者ID:tensorflow,项目名称:models,代码行数:25,代码来源:dcgan_test.py

示例3: test_generator_run

# 需要导入模块: from nets import dcgan [as 别名]
# 或者: from nets.dcgan import generator [as 别名]
def test_generator_run(self):
    tf.set_random_seed(1234)
    noise = tf.random_normal([100, 64])
    image, _ = dcgan.generator(noise)
    with self.test_session() as sess:
      sess.run(tf.global_variables_initializer())
      image.eval() 
开发者ID:leimao,项目名称:DeepLab_v3,代码行数:9,代码来源:dcgan_test.py

示例4: test_generator_invalid_input

# 需要导入模块: from nets import dcgan [as 别名]
# 或者: from nets.dcgan import generator [as 别名]
def test_generator_invalid_input(self):
    wrong_dim_input = tf.zeros([5, 32, 32])
    with self.assertRaises(ValueError):
      dcgan.generator(wrong_dim_input)

    correct_input = tf.zeros([3, 2])
    with self.assertRaisesRegexp(ValueError, 'must be a power of 2'):
      dcgan.generator(correct_input, final_size=30)

    with self.assertRaisesRegexp(ValueError, 'must be greater than 8'):
      dcgan.generator(correct_input, final_size=4) 
开发者ID:leimao,项目名称:DeepLab_v3,代码行数:13,代码来源:dcgan_test.py


注:本文中的nets.dcgan.generator方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。