示例#1
0
    def testTensorConversion(self):
        class TupleToTensor(training.Model):
            def __init__(self):
                super(TupleToTensor, self).__init__()
                self.l = (1., 2., 3.)

        self.assertAllEqual(
            (1., 2., 3.),
            self.evaluate(constant_op.constant(TupleToTensor().l)))

        self.assertAllEqual(
            (1., 2., 3.),
            self.evaluate(gen_array_ops.Pack(values=TupleToTensor().l)))
示例#2
0
    def testTensorConversion(self):
        class ListToTensor(training.Model):
            def __init__(self):
                super(ListToTensor, self).__init__()
                self.l = [1., 2., 3.]

        self.assertAllEqual([1., 2., 3.],
                            self.evaluate(
                                constant_op.constant(ListToTensor().l)))

        self.assertAllEqual([1., 2., 3.],
                            self.evaluate(
                                gen_array_ops.Pack(values=ListToTensor().l)))