示例#1
0
    def test_string(self):
        def fn(entry_lt):
            op = string_ops.string_join([entry_lt, 'world'])
            return core.LabeledTensor(op, [])

        tensor_lt = ops.constant(['hi', 'bye'], axes=['batch'])
        map_lt = ops.map_fn(fn, tensor_lt)
        golden_lt = ops.constant(['hiworld', 'byeworld'], axes=['batch'])

        self.assertLabeledTensorsEqual(map_lt, golden_lt)
示例#2
0
  def test_string(self):

    def fn(entry_lt):
      op = string_ops.string_join([entry_lt, 'world'])
      return core.LabeledTensor(op, [])

    tensor_lt = ops.constant(['hi', 'bye'], axes=['batch'])
    map_lt = ops.map_fn(fn, tensor_lt)
    golden_lt = ops.constant(['hiworld', 'byeworld'], axes=['batch'])

    self.assertLabeledTensorsEqual(map_lt, golden_lt)
示例#3
0
 def test_existing_axes(self):
     golden_lt = core.LabeledTensor(constant_op.constant([1, 2]), ['x'])
     constant_lt = ops.constant([1, 2], axes=golden_lt.axes)
     self.assertLabeledTensorsEqual(constant_lt, golden_lt)
示例#4
0
 def test_specify_shape(self):
     constant_lt = ops.constant(1, axes=[('x', 3)])
     golden_lt = core.LabeledTensor(constant_op.constant(1, shape=(3, )),
                                    ['x'])
     self.assertLabeledTensorsEqual(constant_lt, golden_lt)
示例#5
0
 def test_infer_shape(self):
     constant_lt = ops.constant([1, 2], axes=['x'])
     golden_lt = core.LabeledTensor(constant_op.constant([1, 2]), ['x'])
     self.assertLabeledTensorsEqual(constant_lt, golden_lt)
示例#6
0
 def test_scalar(self):
     constant_lt = ops.constant(1)
     golden_lt = core.LabeledTensor(constant_op.constant(1), [])
     self.assertLabeledTensorsEqual(constant_lt, golden_lt)
示例#7
0
 def test_name(self):
     constant_lt = ops.constant(1)
     self.assertIn('lt_constant', constant_lt.name)
示例#8
0
 def test_existing_axes(self):
   golden_lt = core.LabeledTensor(constant_op.constant([1, 2]), ['x'])
   constant_lt = ops.constant([1, 2], axes=golden_lt.axes)
   self.assertLabeledTensorsEqual(constant_lt, golden_lt)
示例#9
0
 def test_specify_shape(self):
   constant_lt = ops.constant(1, axes=[('x', 3)])
   golden_lt = core.LabeledTensor(constant_op.constant(1, shape=(3,)), ['x'])
   self.assertLabeledTensorsEqual(constant_lt, golden_lt)
示例#10
0
 def test_infer_shape(self):
   constant_lt = ops.constant([1, 2], axes=['x'])
   golden_lt = core.LabeledTensor(constant_op.constant([1, 2]), ['x'])
   self.assertLabeledTensorsEqual(constant_lt, golden_lt)
示例#11
0
 def test_scalar(self):
   constant_lt = ops.constant(1)
   golden_lt = core.LabeledTensor(constant_op.constant(1), [])
   self.assertLabeledTensorsEqual(constant_lt, golden_lt)
示例#12
0
 def test_name(self):
   constant_lt = ops.constant(1)
   self.assertIn('lt_constant', constant_lt.name)
示例#13
0
 def test_sum(self):
     initializer_lt = ops.constant([0, 10], axes=['y'])
     tensor_lt = ops.constant([[1, 2], [3, 4], [5, 6]], axes=['x', 'y'])
     foldl_lt = ops.foldl(core.add, tensor_lt, initializer_lt)
     golden_lt = ops.constant([9, 22], axes=['y'])
     self.assertLabeledTensorsEqual(foldl_lt, golden_lt)
示例#14
0
 def test_sum(self):
   initializer_lt = ops.constant([0, 10], axes=['y'])
   tensor_lt = ops.constant([[1, 2], [3, 4], [5, 6]], axes=['x', 'y'])
   foldl_lt = ops.foldl(core.add, tensor_lt, initializer_lt)
   golden_lt = ops.constant([9, 22], axes=['y'])
   self.assertLabeledTensorsEqual(foldl_lt, golden_lt)