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


Python tensorflow.depth_to_space函数代码示例

本文整理汇总了Python中tensorflow.depth_to_space函数的典型用法代码示例。如果您正苦于以下问题:Python depth_to_space函数的具体用法?Python depth_to_space怎么用?Python depth_to_space使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


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

示例1: testDepthInterleavedDepth3

 def testDepthInterleavedDepth3(self):
   x_np = [[[[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]]]]
   block_size = 2
   with self.test_session(use_gpu=False):
     x_tf = tf.depth_to_space(x_np, block_size)
     self.assertAllEqual(x_tf.eval(), [[[[1, 2, 3], [4, 5, 6]],
                                        [[7, 8, 9], [10, 11, 12]]]])
开发者ID:13331151,项目名称:tensorflow,代码行数:7,代码来源:depthtospace_op_test.py

示例2: SubpixelConv2D

def SubpixelConv2D(*args, **kwargs):
    kwargs['output_dim'] = 4*kwargs['output_dim']
    output = lib.ops.conv2d.Conv2D(*args, **kwargs)
    output = tf.transpose(output, [0,2,3,1])
    output = tf.depth_to_space(output, 2)
    output = tf.transpose(output, [0,3,1,2])
    return output
开发者ID:uotter,项目名称:improved_wgan_training,代码行数:7,代码来源:gan_64x64.py

示例3: testBlockSize0

 def testBlockSize0(self):
   x_np = [[[[1], [2]],
            [[3], [4]]]]
   block_size = 0
   with self.assertRaises(ValueError):
     out_tf = tf.depth_to_space(x_np, block_size)
     out_tf.eval()
开发者ID:AdamPalmar,项目名称:tensorflow,代码行数:7,代码来源:depthtospace_op_test.py

示例4: depth_to_space

def depth_to_space(input, scale, data_format=None):
    ''' Uses phase shift algorithm to convert channels/depth for spatial resolution '''
    data_format = 'NHWC'

    data_format = data_format.lower()
    out = tf.depth_to_space(input, scale, data_format=data_format)
    return out
开发者ID:AlexBlack2202,项目名称:ImageAI,代码行数:7,代码来源:tensorflow_backend.py

示例5: testDepthInterleaved

 def testDepthInterleaved(self):
   x_np = [[[[1, 10, 2, 20, 3, 30, 4, 40]]]]
   block_size = 2
   with self.test_session(use_gpu=False):
     x_tf = tf.depth_to_space(x_np, block_size)
     self.assertAllEqual(x_tf.eval(), [[[[1, 10], [2, 20]],
                                        [[3, 30], [4, 40]]]])
开发者ID:13331151,项目名称:tensorflow,代码行数:7,代码来源:depthtospace_op_test.py

示例6: deconv2d

 def deconv2d(cur, i):
   thicker = conv(
       cur,
       output_filters * 4, (1, 1),
       padding="SAME",
       activation=tf.nn.relu,
       name="deconv2d" + str(i))
   return tf.depth_to_space(thicker, 2)
开发者ID:TrunksLegendary,项目名称:tensor2tensor,代码行数:8,代码来源:common_layers.py

示例7: UpsampleConv

def UpsampleConv(name, input_dim, output_dim, filter_size, inputs, he_init=True, biases=True):
    output = inputs
    output = tf.concat([output, output, output, output], axis=1)
    output = tf.transpose(output, [0,2,3,1])
    output = tf.depth_to_space(output, 2)
    output = tf.transpose(output, [0,3,1,2])
    output = lib.ops.conv2d.Conv2D(name, input_dim, output_dim, filter_size, output, he_init=he_init, biases=biases)
    return output
开发者ID:uotter,项目名称:improved_wgan_training,代码行数:8,代码来源:gan_64x64.py

示例8: testBlockSizeOne

 def testBlockSizeOne(self):
   x_np = [[[[1, 1, 1, 1],
             [2, 2, 2, 2]],
            [[3, 3, 3, 3],
             [4, 4, 4, 4]]]]
   block_size = 1
   with self.assertRaises(ValueError):
     out_tf = tf.depth_to_space(x_np, block_size)
     out_tf.eval()
开发者ID:AdamPalmar,项目名称:tensorflow,代码行数:9,代码来源:depthtospace_op_test.py

示例9: testBlockSize4FlatInput

 def testBlockSize4FlatInput(self):
   x_np = [[[[1, 2, 5, 6, 3, 4, 7, 8, 9, 10, 13, 14, 11, 12, 15, 16]]]]
   block_size = 4
   with self.test_session(use_gpu=False):
     x_tf = tf.depth_to_space(x_np, block_size)
     self.assertAllEqual(x_tf.eval(), [[[[1], [2], [5], [6]],
                                        [[3], [4], [7], [8]],
                                        [[9], [10], [13], [14]],
                                        [[11], [12], [15], [16]]]])
开发者ID:13331151,项目名称:tensorflow,代码行数:9,代码来源:depthtospace_op_test.py

示例10: depth_to_space

 def depth_to_space(cls, ipt, scale, data_format=None):
     """ Uses phase shift algorithm to convert channels/depth
         for spatial resolution """
     if data_format is None:
         data_format = K.image_data_format()
     data_format = data_format.lower()
     ipt = cls._preprocess_conv2d_input(ipt, data_format)
     out = tf.depth_to_space(ipt, scale)
     out = cls._postprocess_conv2d_output(out, data_format)
     return out
开发者ID:stonezuohui,项目名称:faceswap,代码行数:10,代码来源:layers.py

示例11: phase_shift

def phase_shift(x, upsampling_factor=2, data_format="NCHW", name="PhaseShift"):

    if data_format == "NCHW":
        x = tf.transpose(x, [0,2,3,1])

    x = tf.depth_to_space(x, upsampling_factor, name=name)

    if data_format == "NCHW":
        x = tf.transpose(x, [0,3,1,2])

    return x
开发者ID:MiG-Kharkov,项目名称:DeepLearningImplementations,代码行数:11,代码来源:layers.py

示例12: testDepthToSpaceTranspose

 def testDepthToSpaceTranspose(self):
   x = np.arange(20 * 5 * 8 * 7, dtype=np.float32).reshape([20, 5, 8, 7])
   block_size = 2
   crops = np.zeros((2, 2), dtype=np.int32)
   y1 = tf.batch_to_space(x, crops, block_size=block_size)
   y2 = tf.transpose(
       tf.depth_to_space(
           tf.transpose(x, [3, 1, 2, 0]), block_size=block_size),
       [3, 1, 2, 0])
   with self.test_session():
     self.assertAllEqual(y1.eval(), y2.eval())
开发者ID:0ruben,项目名称:tensorflow,代码行数:11,代码来源:batchtospace_op_test.py

示例13: testBlockSizeTooLarge

 def testBlockSizeTooLarge(self):
   x_np = [[[[1, 2, 3, 4],
             [5, 6, 7, 8]],
            [[9, 10, 11, 12],
             [13, 14, 15, 16]]]]
   block_size = 4
   # Raise an exception, since th depth is only 4 and needs to be
   # divisible by 16.
   with self.assertRaises(IndexError):
     out_tf = tf.depth_to_space(x_np, block_size)
     out_tf.eval()
开发者ID:AdamPalmar,项目名称:tensorflow,代码行数:11,代码来源:depthtospace_op_test.py

示例14: decompress_step

def decompress_step(source, hparams, first_relu, is_2d, name):
  """Decompression function."""
  with tf.variable_scope(name):
    shape = common_layers.shape_list(source)
    multiplier = 4 if is_2d else 2
    kernel = (1, 1) if is_2d else (1, 1)
    thicker = common_layers.conv_block(
        source, hparams.hidden_size * multiplier, [((1, 1), kernel)],
        first_relu=first_relu, name="decompress_conv")
    if is_2d:
      return tf.depth_to_space(thicker, 2)
    return tf.reshape(thicker, [shape[0], shape[1] * 2, 1, hparams.hidden_size])
开发者ID:kltony,项目名称:tensor2tensor,代码行数:12,代码来源:transformer_vae.py

示例15: testDepthInterleavedLarger

 def testDepthInterleavedLarger(self):
   x_np = [[[[1, 10, 2, 20, 3, 30, 4, 40],
             [5, 50, 6, 60, 7, 70, 8, 80]],
            [[9, 90, 10, 100, 11, 110, 12, 120],
             [13, 130, 14, 140, 15, 150, 16, 160]]]]
   block_size = 2
   with self.test_session(use_gpu=False):
     x_tf = tf.depth_to_space(x_np, block_size)
     self.assertAllEqual(x_tf.eval(),
                         [[[[1, 10], [2, 20], [5, 50], [6, 60]],
                           [[3, 30], [4, 40], [7, 70], [8, 80]],
                           [[9, 90], [10, 100], [13, 130], [14, 140]],
                           [[11, 110], [12, 120], [15, 150], [16, 160]]]])
开发者ID:13331151,项目名称:tensorflow,代码行数:13,代码来源:depthtospace_op_test.py


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