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


Python ops.select函数代码示例

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


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

示例1: setUp

  def setUp(self):
    super(Base, self).setUp()

    self.x_size = 7
    self.channel_size = 3
    self.z_size = 4
    self.probs_size = 11

    tensor = math_ops.range(0, self.x_size * self.channel_size * self.z_size *
                            self.probs_size)
    tensor = array_ops.reshape(
        tensor, [self.x_size, self.channel_size, self.z_size, self.probs_size])
    a0 = ('x', range(self.x_size))
    a1 = ('channel', ['red', 'green', 'blue'])
    a2 = 'z'
    a3 = ('probs', np.linspace(0.0, 1.0, self.probs_size))

    self.tensor = tensor
    self.a0 = a0
    self.a1 = a1
    self.a2 = a2
    self.a2_resolved = ('z', self.z_size)
    self.a3 = a3
    self.original_lt = core.LabeledTensor(tensor, [a0, a1, a2, a3])

    self.x_probs_lt = core.slice_function(self.original_lt, {'z': 0})
    self.x_probs_lt = ops.select(self.x_probs_lt, {'channel': 'red'})
    self.channel_probs_lt = core.slice_function(self.original_lt,
                                                {'x': 3,
                                                 'z': 0})
开发者ID:AliMiraftab,项目名称:tensorflow,代码行数:30,代码来源:ops_test.py

示例2: test_invalid_input

 def test_invalid_input(self):
     with self.assertRaises(ValueError):
         rc = sugar.ReshapeCoder(["channel", "mask"], ["depth"])
         rc.decode(self.masked_image_lt)
     with self.assertRaises(ValueError):
         rc = sugar.ReshapeCoder(["channel", "mask"], ["depth"])
         rc.encode(self.masked_image_lt)
         rc.encode(ops.select(self.masked_image_lt, {"channel": "red"}))
开发者ID:kdavis-mozilla,项目名称:tensorflow,代码行数:8,代码来源:sugar_test.py

示例3: test_invalid_input

 def test_invalid_input(self):
   with self.assertRaises(ValueError):
     rc = sugar.ReshapeCoder(['channel', 'mask'], ['depth'])
     rc.decode(self.masked_image_lt)
   with self.assertRaises(ValueError):
     rc = sugar.ReshapeCoder(['channel', 'mask'], ['depth'])
     rc.encode(self.masked_image_lt)
     rc.encode(ops.select(self.masked_image_lt, {'channel': 'red'}))
开发者ID:1000sprites,项目名称:tensorflow,代码行数:8,代码来源:sugar_test.py

示例4: test_slices

  def test_slices(self):
    select_lt = ops.select(self.original_lt, {'x': slice(1, 4),
                                              'channel': slice('green', None)})

    a0_sliced = ('x', range(1, 5))
    a1_sliced = ('channel', ['green', 'blue'])
    golden_lt = core.LabeledTensor(self.tensor[1:5, 1:, :, :],
                                   [a0_sliced, a1_sliced, self.a2, self.a3])
    self.assertLabeledTensorsEqual(select_lt, golden_lt)
开发者ID:curtiszimmerman,项目名称:tensorflow,代码行数:9,代码来源:ops_test.py

示例5: test_list

 def test_list(self):
   select_lt = ops.select(self.original_lt, {'channel': ['red', 'green']})
   a1_sliced = ('channel', ['red', 'green'])
   golden_lt = core.LabeledTensor(self.tensor[:, :2, :, :],
                                  [self.a0, a1_sliced, self.a2, self.a3])
   self.assertLabeledTensorsEqual(select_lt, golden_lt)
开发者ID:AliMiraftab,项目名称:tensorflow,代码行数:6,代码来源:ops_test.py

示例6: test_scalar

 def test_scalar(self):
   select_lt = ops.select(self.original_lt, {'channel': 'green'})
   golden_lt = core.LabeledTensor(self.tensor[:, 1, :, :],
                                  [self.a0, self.a2, self.a3])
   self.assertLabeledTensorsEqual(select_lt, golden_lt)
开发者ID:AliMiraftab,项目名称:tensorflow,代码行数:5,代码来源:ops_test.py

示例7: test_name

 def test_name(self):
   select_lt = ops.select(self.original_lt, {'channel': 'green'})
   self.assertIn('lt_select', select_lt.name)
开发者ID:AliMiraftab,项目名称:tensorflow,代码行数:3,代码来源:ops_test.py

示例8: test

  def test(self):
    concat_lt = ops.concat([self.red_lt, self.green_lt], 'channel')
    golden_lt = ops.select(self.original_lt, {'channel': ['red', 'green']})

    self.assertLabeledTensorsEqual(concat_lt, golden_lt)
开发者ID:AliMiraftab,项目名称:tensorflow,代码行数:5,代码来源:ops_test.py

示例9: test_invalid_input

 def test_invalid_input(self):
   with self.assertRaises(ValueError):
     ops.select(self.original_lt, {'foo': 1})
   with self.assertRaises(ValueError):
     ops.select(self.original_lt, {'z': 1})
   with self.assertRaises(KeyError):
     ops.select(self.original_lt, {'channel': 'purple'})
   with self.assertRaises(KeyError):
     ops.select(self.original_lt, {'channel': ['red', 'purple']})
   with self.assertRaises(NotImplementedError):
     ops.select(self.original_lt, {'channel': ['red'], 'x': [1]})
   with self.assertRaises(NotImplementedError):
     ops.select(self.original_lt, {'channel': ['red'], 'x': 1})
   with self.assertRaises(NotImplementedError):
     ops.select(self.original_lt, {'channel': slice('red', 'green', 2)})
开发者ID:AliMiraftab,项目名称:tensorflow,代码行数:15,代码来源:ops_test.py

示例10: test_list_zero_items

 def test_list_zero_items(self):
   select_lt = ops.select(self.original_lt, {'channel': []})
   golden_lt = core.LabeledTensor(self.tensor[:, :0, :, :],
                                  [self.a0, 'channel', self.a2, self.a3])
   self.assertLabeledTensorsEqual(select_lt, golden_lt)
开发者ID:AliMiraftab,项目名称:tensorflow,代码行数:5,代码来源:ops_test.py

示例11: test_tuple

 def test_tuple(self):
   original_lt = core.LabeledTensor(constant_op.constant([5, 6]),
                                    [('x', [(1, 2), (3, 4)])])
   select_lt = ops.select(original_lt, {'x': (1, 2)})
   golden_lt = core.LabeledTensor(constant_op.constant(5), [])
   self.assertLabeledTensorsEqual(select_lt, golden_lt)
开发者ID:Ajaycs99,项目名称:tensorflow,代码行数:6,代码来源:ops_test.py


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