MCPcopy Create free account
hub / github.com/davisking/dlib / compare_adam

Function compare_adam

dlib/test/dnn.cpp:1583–1611  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1581 }
1582
1583 void compare_adam()
1584 {
1585 float t = 2;
1586 tt::tensor_rand rnd;
1587 resizable_tensor s, m, v, params, params_grad;
1588 s.set_size(89,90,60,73);
1589 m.copy_size(s);
1590 v.copy_size(s);
1591 params.copy_size(s);
1592 params_grad.copy_size(s);
1593
1594 rnd.fill_uniform(s);
1595 rnd.fill_uniform(m);
1596 rnd.fill_uniform(v);
1597 rnd.fill_uniform(params);
1598 rnd.fill_uniform(params_grad);
1599
1600 resizable_tensor mm(m), vv(v);
1601 cpu::compute_adam_update(0,params.size(),s, mm, vv, t, 0.01, 0.001, 0.9, 0.99, params, params_grad);
1602 matrix<float> s1 = mat(s);
1603
1604 rnd.fill_uniform(s);
1605 cuda::compute_adam_update(0,params.size(),s, m, v, t, 0.01, 0.001, 0.9, 0.99, params, params_grad);
1606 matrix<float> s2 = mat(s);
1607
1608 DLIB_TEST_MSG(max(abs(s1-s2)) < 1e-6, max(abs(s1-s2)));
1609 DLIB_TEST_MSG(max(abs(mat(m)-mat(mm))) < 1e-6, max(abs(mat(m)-mat(mm))));
1610 DLIB_TEST_MSG(max(abs(mat(v)-mat(vv))) < 1e-6, max(abs(mat(v)-mat(vv))));
1611 }
1612
1613 void test_multiply_zero_padded()
1614 {

Callers 1

run_testsMethod · 0.85

Calls 7

absFunction · 0.85
copy_sizeMethod · 0.80
compute_adam_updateFunction · 0.50
matFunction · 0.50
maxFunction · 0.50
set_sizeMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected