Ejemplo n.º 1
0
  def test_get_item_tensor_string(self):
    initial_str = constant_op.constant('abcd')
    t = slices.get_item(initial_str, 1,
                        slices.GetItemOpts(element_dtype=initial_str.dtype))

    with self.cached_session() as sess:
      self.assertEqual(self.evaluate(t), b'b')

    initial_list_str = constant_op.constant(['abcd', 'bcde'])
    t = slices.get_item(initial_list_str, 1,
                        slices.GetItemOpts(element_dtype=initial_str.dtype))

    with self.cached_session() as sess:
      self.assertEqual(self.evaluate(t), b'bcde')
Ejemplo n.º 2
0
    def test_get_item_tensor_string(self):
        initial_str = constant_op.constant('abcd')
        t = slices.get_item(
            initial_str, 1,
            slices.GetItemOpts(element_dtype=initial_str.dtype))

        with self.cached_session() as sess:
            self.assertEqual(self.evaluate(t), b'b')

        initial_list_str = constant_op.constant(['abcd', 'bcde'])
        t = slices.get_item(
            initial_list_str, 1,
            slices.GetItemOpts(element_dtype=initial_str.dtype))

        with self.cached_session() as sess:
            self.assertEqual(self.evaluate(t), b'bcde')
Ejemplo n.º 3
0
  def test_get_item_tensor_list(self):
    initial_list = constant_op.constant([[1, 2], [3, 4]])
    elem_shape = constant_op.constant([2])
    l = list_ops.tensor_list_from_tensor(initial_list, element_shape=elem_shape)
    t = slices.get_item(
        l, 1, slices.GetItemOpts(element_dtype=initial_list.dtype))

    with self.cached_session() as sess:
      self.assertAllEqual(self.evaluate(t), [3, 4])
Ejemplo n.º 4
0
    def test_get_item_tensor_list(self):
        initial_list = constant_op.constant([[1, 2], [3, 4]])
        elem_shape = constant_op.constant([2])
        l = list_ops.tensor_list_from_tensor(initial_list,
                                             element_shape=elem_shape)
        t = slices.get_item(
            l, 1, slices.GetItemOpts(element_dtype=initial_list.dtype))

        with self.cached_session() as sess:
            self.assertAllEqual(self.evaluate(t), [3, 4])