Example #1
0
def test_generic_compute_Lx_batches():

    ## now compare against theano version
    vv = T.matrix()
    gg = T.matrix()
    hh = T.matrix()
    aa = T.vector()
    bb = T.vector()
    cc = T.vector()
    xxw_mat = T.matrix()
    xxv_mat = T.matrix()
    xxw = T.vector()
    xxv = T.vector()
    xxa = T.vector()
    xxb = T.vector()
    xxc = T.vector()

    # test compute_Lx
    LLx = natural.generic_compute_Lx_batches([vv, gg, hh],
                                             [xxw_mat, xxv_mat],
                                             [xxa, xxb, xxc],
                                             256, 64)
    f = theano.function([vv, gg, hh, xxw_mat, xxv_mat, xxa, xxb, xxc], LLx)
    t1 = time.time()
    rvals = f(v, g, h, xw_mat, xv_mat, xa, xb, xc)
    print 'Elapsed: ', time.time() - t1
    numpy.testing.assert_almost_equal(Lx_w, rvals[0], decimal=3)
    numpy.testing.assert_almost_equal(Lx_v, rvals[1], decimal=3)
    numpy.testing.assert_almost_equal(Lx_a, rvals[2], decimal=3)
    numpy.testing.assert_almost_equal(Lx_b, rvals[3], decimal=3)
    numpy.testing.assert_almost_equal(Lx_c, rvals[4], decimal=3)
Example #2
0
def test_generic_compute_Lx_batches():

    ## now compare against theano version
    vv = T.matrix()
    gg = T.matrix()
    hh = T.matrix()
    aa = T.vector()
    bb = T.vector()
    cc = T.vector()
    xxw_mat = T.matrix()
    xxv_mat = T.matrix()
    xxw = T.vector()
    xxv = T.vector()
    xxa = T.vector()
    xxb = T.vector()
    xxc = T.vector()

    # test compute_Lx
    LLx = natural.generic_compute_Lx_batches([vv, gg, hh], [xxw_mat, xxv_mat],
                                             [xxa, xxb, xxc], 256, 64)
    f = theano.function([vv, gg, hh, xxw_mat, xxv_mat, xxa, xxb, xxc], LLx)
    t1 = time.time()
    rvals = f(v, g, h, xw_mat, xv_mat, xa, xb, xc)
    print 'Elapsed: ', time.time() - t1
    numpy.testing.assert_almost_equal(Lx_w, rvals[0], decimal=3)
    numpy.testing.assert_almost_equal(Lx_v, rvals[1], decimal=3)
    numpy.testing.assert_almost_equal(Lx_a, rvals[2], decimal=3)
    numpy.testing.assert_almost_equal(Lx_b, rvals[3], decimal=3)
    numpy.testing.assert_almost_equal(Lx_c, rvals[4], decimal=3)
Example #3
0
def test_generic_compute_Lx_batches():

    ## now compare against theano version
    vv = T.matrix()
    gg = T.matrix()
    hh = T.matrix()
    qq = T.matrix()
    aa = T.vector()
    bb = T.vector()
    cc = T.vector()
    dd = T.vector()
    xxw_mat = T.matrix()
    xxv_mat = T.matrix()
    xxz_mat = T.matrix()
    xxw = T.vector()
    xxv = T.vector()
    xxa = T.vector()
    xxb = T.vector()
    xxc = T.vector()
    xxd = T.vector()

    # test compute_Lx
    LLx = natural.generic_compute_Lx_batches([vv, gg, hh, qq],
                                             [xxw_mat, xxv_mat, xxz_mat],
                                             [xxa, xxb, xxc, xxd], 256, 64)
    f = theano.function(
        [vv, gg, hh, qq, xxw_mat, xxv_mat, xxz_mat, xxa, xxb, xxc, xxd], LLx)
    rvals = f(v, g, h, q, xw_mat, xv_mat, xz_mat, xa, xb, xc, xd)
    numpy.testing.assert_almost_equal(Lx_w, rvals[0], decimal=3)
    numpy.testing.assert_almost_equal(Lx_v, rvals[1], decimal=3)
    numpy.testing.assert_almost_equal(Lx_z, rvals[2], decimal=3)
    numpy.testing.assert_almost_equal(Lx_a, rvals[3], decimal=3)
    numpy.testing.assert_almost_equal(Lx_b, rvals[4], decimal=3)
    numpy.testing.assert_almost_equal(Lx_c, rvals[5], decimal=3)
    numpy.testing.assert_almost_equal(Lx_d, rvals[6], decimal=3)
Example #4
0
def test_generic_compute_Lx_batches():

    ## now compare against theano version
    vv = T.matrix()
    gg = T.matrix()
    hh = T.matrix()
    qq = T.matrix()
    aa = T.vector()
    bb = T.vector()
    cc = T.vector()
    dd = T.vector()
    xxw_mat = T.matrix()
    xxv_mat = T.matrix()
    xxz_mat = T.matrix()
    xxw = T.vector()
    xxv = T.vector()
    xxa = T.vector()
    xxb = T.vector()
    xxc = T.vector()
    xxd = T.vector()

    # test compute_Lx
    LLx = natural.generic_compute_Lx_batches([vv, gg, hh, qq],
                                             [xxw_mat, xxv_mat, xxz_mat],
                                             [xxa, xxb, xxc, xxd],
                                             256, 64)
    f = theano.function([vv, gg, hh, qq, xxw_mat, xxv_mat, xxz_mat, xxa, xxb, xxc, xxd], LLx)
    rvals = f(v, g, h, q, xw_mat, xv_mat, xz_mat, xa, xb, xc, xd)
    numpy.testing.assert_almost_equal(Lx_w, rvals[0], decimal=3)
    numpy.testing.assert_almost_equal(Lx_v, rvals[1], decimal=3)
    numpy.testing.assert_almost_equal(Lx_z, rvals[2], decimal=3)
    numpy.testing.assert_almost_equal(Lx_a, rvals[3], decimal=3)
    numpy.testing.assert_almost_equal(Lx_b, rvals[4], decimal=3)
    numpy.testing.assert_almost_equal(Lx_c, rvals[5], decimal=3)
    numpy.testing.assert_almost_equal(Lx_d, rvals[6], decimal=3)