

def test_gdm(backend_default):
    (lrate, mom, wdecay) = (0.1, 0.9, 0.005)
    gdm = GradientDescentMomentum(learning_rate=lrate, momentum_coef=mom, wdecay=wdecay)
    param = np.random.rand(200, 128)
    param2 = copy.deepcopy(param)
    grad = (0.01 * np.random.rand(200, 128))
    grad2 = (grad / 128.0)
    states = [(0.01 * np.random.rand(200, 128))]
    velocity = states[0]
    param2[:] = (((param2 + (velocity * mom)) - (grad2 * lrate)) - ((wdecay * lrate) * param))
    param_list = [((wrap(param), wrap(grad)), [wrap(states[0])])]
    compare_tensors(gdm, param_list, param2, tol=1e-07)

dataset/ETHPy150Open NervanaSystems/neon/tests/test_optimizer.py test_gdm/original