| 792 | } |
| 793 | |
| 794 | void test_mish() |
| 795 | { |
| 796 | IF_DLIB_USE_CUDA( |
| 797 | // make sure that cuda::mish and cpu::mish return the same results |
| 798 | using namespace dlib::tt; |
| 799 | print_spinner(); |
| 800 | const long n = 4; |
| 801 | const long k = 5; |
| 802 | const long nr = 3; |
| 803 | const long nc = 3; |
| 804 | resizable_tensor src(n,k,nr,nc); |
| 805 | tt::tensor_rand rnd; |
| 806 | rnd.fill_gaussian(src); |
| 807 | |
| 808 | resizable_tensor dest1, dest2; |
| 809 | dest1.copy_size(src); |
| 810 | dest2.copy_size(src); |
| 811 | // initialize to different values in order to make sure the output is actually changed |
| 812 | dest1 = 1; |
| 813 | dest2 = 2; |
| 814 | cuda::mish(dest1, src); |
| 815 | cpu::mish(dest2, src); |
| 816 | DLIB_TEST_MSG(max(abs(mat(dest1) - mat(dest2))) < 1e-6, max(abs(mat(dest1) - mat(dest2)))); |
| 817 | ) |
| 818 | } |
| 819 | |
| 820 | void test_leaky_relu() |
| 821 | { |