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


Python list_ops.tensor_list_length函数代码示例

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


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

示例1: testTensorListFromTensor

 def testTensorListFromTensor(self):
   t = constant_op.constant([1.0, 2.0])
   l = list_ops.tensor_list_from_tensor(t, element_shape=[])
   l, e = list_ops.tensor_list_pop_back(l, element_dtype=dtypes.float32)
   self.assertAllEqual(self.evaluate(e), 2.0)
   l, e = list_ops.tensor_list_pop_back(l, element_dtype=dtypes.float32)
   self.assertAllEqual(self.evaluate(e), 1.0)
   self.assertAllEqual(self.evaluate(list_ops.tensor_list_length(l)), 0)
开发者ID:aeverall,项目名称:tensorflow,代码行数:8,代码来源:list_ops_test.py

示例2: body

      def body(i, m, t1):
        t1 = control_flow_ops.cond(
            math_ops.equal(list_ops.tensor_list_length(t1), 0),
            lambda: list_ops.empty_tensor_list(m.shape, m.dtype), lambda: t1)

        t1 = list_ops.tensor_list_push_back(t1, m * i)
        i += 1.0
        return i, m, t1
开发者ID:aeverall,项目名称:tensorflow,代码行数:8,代码来源:list_ops_test.py

示例3: testUnevenSplit

 def testUnevenSplit(self):
   l = list_ops.tensor_list_split([1., 2., 3., 4., 5],
                                  element_shape=None,
                                  lengths=[3, 2])
   self.assertAllEqual(list_ops.tensor_list_length(l), 2)
   self.assertAllEqual(
       list_ops.tensor_list_get_item(l, 0, element_dtype=dtypes.float32),
       [1., 2., 3.])
   self.assertAllEqual(
       list_ops.tensor_list_get_item(l, 1, element_dtype=dtypes.float32),
       [4., 5.])
开发者ID:aeverall,项目名称:tensorflow,代码行数:11,代码来源:list_ops_test.py

示例4: testListFromTensor

 def testListFromTensor(self):
   with self.cached_session(), self.test_scope():
     t = constant_op.constant([1.0, 2.0])
     l = list_ops.tensor_list_from_tensor(t, element_shape=[])
     e = list_ops.tensor_list_get_item(l, 0, element_dtype=dtypes.float32)
     self.assertAllEqual(e, 1.0)
     l, e0 = list_ops.tensor_list_pop_back(l, element_dtype=dtypes.float32)
     self.assertAllEqual(e0, 2.0)
     l, e1 = list_ops.tensor_list_pop_back(l, element_dtype=dtypes.float32)
     self.assertAllEqual(e1, 1.0)
     self.assertAllEqual(list_ops.tensor_list_length(l), 0)
开发者ID:jackd,项目名称:tensorflow,代码行数:11,代码来源:tensor_list_ops_test.py

示例5: dynamic_len

def dynamic_len(list_or_tensor):
  """Implementation of len using dynamic dispatch."""
  if _is_tensor_list(list_or_tensor):
    return list_ops.tensor_list_length(list_or_tensor)
  elif tensor_util.is_tensor(list_or_tensor):
    shape = list_or_tensor.shape
    if not shape.ndims:
      raise ValueError(
          'len requires non-zero rank for tensor "%s"' % list_or_tensor)
    return array_ops.shape(list_or_tensor)[0]
  return len(list_or_tensor)
开发者ID:ZhangXinNan,项目名称:tensorflow,代码行数:11,代码来源:builtins.py

示例6: _tf_tensor_list_append

def _tf_tensor_list_append(list_, x):
  """Overload of list_append that stages a Tensor list write."""
  def empty_list_of_elements_like_x():
    tensor_x = ops.convert_to_tensor(x)
    return list_ops.empty_tensor_list(
        element_shape=array_ops.shape(tensor_x),
        element_dtype=tensor_x.dtype)

  list_ = control_flow_ops.cond(
      list_ops.tensor_list_length(list_) > 0,
      lambda: list_,
      empty_list_of_elements_like_x,
  )
  return list_ops.tensor_list_push_back(list_, x)
开发者ID:BhaskarNallani,项目名称:tensorflow,代码行数:14,代码来源:data_structures.py

示例7: _tf_tensor_list_len

def _tf_tensor_list_len(s):
  return list_ops.tensor_list_length(s)
开发者ID:adit-chandra,项目名称:tensorflow,代码行数:2,代码来源:py_builtins.py

示例8: size

 def size(self, name=None):
   """See TensorArray."""
   return list_ops.tensor_list_length(input_handle=self._flow, name=name)
开发者ID:aritratony,项目名称:tensorflow,代码行数:3,代码来源:tensor_array_ops.py

示例9: count

 def count(self):
   return list_ops.tensor_list_length(self.list_)
开发者ID:AndrewTwinz,项目名称:tensorflow,代码行数:2,代码来源:tensor_list.py


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