@utt.AttemptManyTimes(n_attempts=3, n_req_successes=1)
def test_run_nnet():
    for n_in in 1024, 2048, 4096:
        for n_hid in 1024, 2048, 4096:
            utt.seed_rng()  # Seeds numpy rng with utt.fetch_seed()
            rval_cpu, tc = run_nnet(False, n_in=n_in, n_hid=n_hid)
            utt.seed_rng()
            rval_gpu, tg = run_nnet(True, n_in=n_in, n_hid=n_hid)
            # print "cpu:", rval_cpu
            # print "gpu:", rval_gpu
            abs_diff, rel_diff = \
                    theano.gradient.numeric_grad.abs_rel_err(rval_gpu,
                                                             rval_cpu)
            max_abs_diff = abs_diff.max()
            # print "max abs diff=%e max rel diff=%e n_in=%d n_hid=%d" % (
            #    max_abs_diff, rel_diff.max(), n_in, n_hid)
            # print "time cpu: %f, time gpu: %f, speed up %f" % (tc, tg, tc / tg)
            rtol = 1e-4
            if 2048 * 4096 >= n_in * n_hid:
                rtol = 7e-4
            assert numpy.allclose(rval_cpu, rval_gpu, rtol=rtol, atol=1e-6), \
                   ("max_abs_diff, max_rel_diff, n_in, n_hid", max_abs_diff,
                    rel_diff.max(), n_in, n_hid)
dataset/ETHPy150Open rizar/attention-lvcsr/libs/Theano/theano/sandbox/cuda/tests/test_mlp.py/test_run_nnet/swapped operands of `>=`