Пример #1
0
    def test_wrong_input(self):
        mySymbolicMatricesList = TypedListType(
            T.TensorType(theano.config.floatX, (False, False)))()
        mySymbolicMatrix = T.matrix()

        self.assertRaises(TypeError, GetItem(), mySymbolicMatricesList,
                          mySymbolicMatrix)
Пример #2
0
    def test_wrong_input(self):
        mySymbolicMatricesList = TypedListType(
            T.TensorType(theano.config.floatX, (False, False)))()
        mySymbolicMatrix = T.matrix()

        with pytest.raises(TypeError):
            GetItem()(mySymbolicMatricesList, mySymbolicMatrix)
Пример #3
0
    def test_constant_input(self):
        mySymbolicMatricesList = TypedListType(
            T.TensorType(theano.config.floatX, (False, False)))()

        z = GetItem()(mySymbolicMatricesList, 0)

        f = theano.function([mySymbolicMatricesList], z)

        x = rand_ranged_matrix(-1000, 1000, [100, 101])

        self.assertTrue(numpy.array_equal(f([x]), x))

        z = GetItem()(mySymbolicMatricesList, slice(0, 1, 1))

        f = theano.function([mySymbolicMatricesList], z)

        self.assertTrue(numpy.array_equal(f([x]), [x]))
Пример #4
0
    def test_sanity_check_single(self):

        mySymbolicMatricesList = TypedListType(
            T.TensorType(theano.config.floatX, (False, False)))()

        mySymbolicScalar = T.scalar()

        z = GetItem()(mySymbolicMatricesList, mySymbolicScalar)

        f = theano.function([mySymbolicMatricesList, mySymbolicScalar], z)

        x = rand_ranged_matrix(-1000, 1000, [100, 101])

        self.assertTrue(numpy.array_equal(f([x], numpy.asarray(0)), x))
Пример #5
0
    def test_sanity_check_single(self):

        mySymbolicMatricesList = TypedListType(
            tt.TensorType(theano.config.floatX, (False, False))
        )()

        mySymbolicScalar = tt.scalar(dtype="int64")

        z = GetItem()(mySymbolicMatricesList, mySymbolicScalar)

        f = theano.function([mySymbolicMatricesList, mySymbolicScalar], z)

        x = rand_ranged_matrix(-1000, 1000, [100, 101])

        assert np.array_equal(f([x], np.asarray(0, dtype="int64")), x)
Пример #6
0
    def test_sanity_check_slice(self):

        mySymbolicMatricesList = TypedListType(
            T.TensorType(theano.config.floatX, (False, False)))()

        mySymbolicSlice = SliceType()()

        z = GetItem()(mySymbolicMatricesList, mySymbolicSlice)

        self.assertFalse(isinstance(z, T.TensorVariable))

        f = theano.function([mySymbolicMatricesList, mySymbolicSlice], z)

        x = rand_ranged_matrix(-1000, 1000, [100, 101])

        self.assertTrue(numpy.array_equal(f([x], slice(0, 1, 1)), [x]))