| 818 | } |
| 819 | |
| 820 | void test_leaky_relu() |
| 821 | { |
| 822 | IF_DLIB_USE_CUDA( |
| 823 | using namespace dlib::tt; |
| 824 | print_spinner(); |
| 825 | const long n = 4; |
| 826 | const long k = 5; |
| 827 | const long nr = 3; |
| 828 | const long nc = 3; |
| 829 | const float alpha = 0.01; |
| 830 | resizable_tensor src(n, k, nr, nc); |
| 831 | tt::tensor_rand rnd; |
| 832 | rnd.fill_gaussian(src); |
| 833 | resizable_tensor dest_cuda, dest_cpu; |
| 834 | dest_cuda.copy_size(src); |
| 835 | dest_cpu.copy_size(src); |
| 836 | // initialize to different values in order to make sure the output is actually changed |
| 837 | dest_cuda = 1; |
| 838 | dest_cpu = 2; |
| 839 | cuda::leaky_relu(dest_cuda, src, alpha); |
| 840 | cpu::leaky_relu(dest_cpu, src, alpha); |
| 841 | |
| 842 | DLIB_TEST_MSG(max(abs(mat(dest_cuda) - mat(dest_cpu))) < 1e-7, max(abs(mat(dest_cuda) - mat(dest_cpu)))); |
| 843 | ) |
| 844 | } |
| 845 | |
| 846 | void test_clipped_relu() |
| 847 | { |
no test coverage detected