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


Python shapes.transposing_reshape方法代码示例

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


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

示例1: testTransposingReshape_2_2_3_2_1

# 需要导入模块: import shapes [as 别名]
# 或者: from shapes import transposing_reshape [as 别名]
def testTransposingReshape_2_2_3_2_1(self):
    """Case: dest_a == src, dest_b < src: Split with Least sig part going left.
    """
    with self.test_session() as sess:
      fake = tf.placeholder(
          tf.float32, shape=(None, None, None, 2), name='inputs')
      outputs = shapes.transposing_reshape(
          fake, src_dim=2, part_a=2, part_b=3, dest_dim_a=2, dest_dim_b=1)
      # Make real inputs. The tensor looks like this:
      # tensor=[[[[0, 1][2, 3][4, 5][6, 7][8, 9][10, 11]]
      #          [[12, 13][14, 15][16, 17][18, 19][20, 21][22, 23]]
      #         [[[24, 25]...
      real = np.arange(120).reshape((5, 2, 6, 2))
      np_array = sess.run([outputs], feed_dict={fake: real})[0]
      self.assertEqual(tuple(np_array.shape), (5, 6, 2, 2))
      self.assertAllEqual(np_array[0, :, :, :],
                          [[[0, 1], [6, 7]], [[12, 13], [18, 19]],
                           [[2, 3], [8, 9]], [[14, 15], [20, 21]],
                           [[4, 5], [10, 11]], [[16, 17], [22, 23]]]) 
开发者ID:ringringyi,项目名称:DOTA_models,代码行数:21,代码来源:shapes_test.py

示例2: testTransposingReshape_2_2_3_2_3

# 需要导入模块: import shapes [as 别名]
# 或者: from shapes import transposing_reshape [as 别名]
def testTransposingReshape_2_2_3_2_3(self):
    """Case: dest_a == src, dest_b > src: Split with Least sig part going right.
    """
    with self.test_session() as sess:
      fake = tf.placeholder(
          tf.float32, shape=(None, None, None, 2), name='inputs')
      outputs = shapes.transposing_reshape(
          fake, src_dim=2, part_a=2, part_b=3, dest_dim_a=2, dest_dim_b=3)
      # Make real inputs. The tensor looks like this:
      # tensor=[[[[0, 1][2, 3][4, 5][6, 7][8, 9][10, 11]]
      #          [[12, 13][14, 15][16, 17][18, 19][20, 21][22, 23]]
      #         [[[24, 25]...
      real = np.arange(120).reshape((5, 2, 6, 2))
      np_array = sess.run([outputs], feed_dict={fake: real})[0]
      self.assertEqual(tuple(np_array.shape), (5, 2, 2, 6))
      self.assertAllEqual(
          np_array[0, :, :, :],
          [[[0, 1, 2, 3, 4, 5], [6, 7, 8, 9, 10, 11]],
           [[12, 13, 14, 15, 16, 17], [18, 19, 20, 21, 22, 23]]]) 
开发者ID:ringringyi,项目名称:DOTA_models,代码行数:21,代码来源:shapes_test.py

示例3: testTransposingReshape_2_2_3_1_2

# 需要导入模块: import shapes [as 别名]
# 或者: from shapes import transposing_reshape [as 别名]
def testTransposingReshape_2_2_3_1_2(self):
    """Case: dest_a < src, dest_b == src. Split with Most sig part going left.
    """
    with self.test_session() as sess:
      fake = tf.placeholder(
          tf.float32, shape=(None, None, None, 2), name='inputs')
      outputs = shapes.transposing_reshape(
          fake, src_dim=2, part_a=2, part_b=3, dest_dim_a=1, dest_dim_b=2)
      # Make real inputs. The tensor looks like this:
      # tensor=[[[[0, 1][2, 3][4, 5][6, 7][8, 9][10, 11]]
      #          [[12, 13][14, 15][16, 17][18, 19][20, 21][22, 23]]
      #         [[[24, 25]...
      real = np.arange(120).reshape((5, 2, 6, 2))
      np_array = sess.run([outputs], feed_dict={fake: real})[0]
      self.assertEqual(tuple(np_array.shape), (5, 4, 3, 2))
      self.assertAllEqual(np_array[0, :, :, :],
                          [[[0, 1], [2, 3], [4, 5]],
                           [[12, 13], [14, 15], [16, 17]],
                           [[6, 7], [8, 9], [10, 11]],
                           [[18, 19], [20, 21], [22, 23]]]) 
开发者ID:ringringyi,项目名称:DOTA_models,代码行数:22,代码来源:shapes_test.py

示例4: testTransposingReshape_2_2_3_3_2

# 需要导入模块: import shapes [as 别名]
# 或者: from shapes import transposing_reshape [as 别名]
def testTransposingReshape_2_2_3_3_2(self):
    """Case: dest_a < src, dest_b == src. Split with Most sig part going right.
    """
    with self.test_session() as sess:
      fake = tf.placeholder(
          tf.float32, shape=(None, None, None, 2), name='inputs')
      outputs = shapes.transposing_reshape(
          fake, src_dim=2, part_a=2, part_b=3, dest_dim_a=3, dest_dim_b=2)
      # Make real inputs. The tensor looks like this:
      # tensor=[[[[0, 1][2, 3][4, 5][6, 7][8, 9][10, 11]]
      #          [[12, 13][14, 15][16, 17][18, 19][20, 21][22, 23]]
      #         [[[24, 25]...
      real = np.arange(120).reshape((5, 2, 6, 2))
      np_array = sess.run([outputs], feed_dict={fake: real})[0]
      self.assertEqual(tuple(np_array.shape), (5, 2, 3, 4))
      self.assertAllEqual(
          np_array[0, :, :, :],
          [[[0, 1, 6, 7], [2, 3, 8, 9], [4, 5, 10, 11]],
           [[12, 13, 18, 19], [14, 15, 20, 21], [16, 17, 22, 23]]]) 
开发者ID:ringringyi,项目名称:DOTA_models,代码行数:21,代码来源:shapes_test.py


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