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

Function test_leaky_relu

dlib/test/dnn.cpp:820–844  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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 {

Callers 1

run_testsMethod · 0.85

Calls 6

print_spinnerFunction · 0.85
absFunction · 0.85
copy_sizeMethod · 0.80
leaky_reluFunction · 0.50
maxFunction · 0.50
matFunction · 0.50

Tested by

no test coverage detected