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

Function test_resize_to

dlib/test/dnn.cpp:5484–5515  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

5482 }
5483
5484 void test_resize_to() {
5485 print_spinner();
5486 const long nr = 8, nc = 12;
5487 const long n_samples = 5, k = 1, h = 4;
5488
5489 using net_type = tag1<reshape_to<k, nr, nc,
5490 flatten<h, nr, nc / h, reshape_to<h, nr, nc / h,
5491 input<matrix<float>>>>>>;
5492 net_type net;
5493
5494 dlib::rand rnd;
5495 std::vector<matrix<float>> x(n_samples);
5496 matrix<float> xtmp(nr, nc);
5497 for (int ii = 0; ii < n_samples; ++ii) {
5498 for (int jj = 0; jj < nr; ++jj)
5499 for (int kk = 0; kk < nc; ++kk)
5500 xtmp(jj, kk) = rnd.get_random_gaussian();
5501 x[ii] = xtmp;
5502 }
5503
5504 resizable_tensor input_tensor;
5505 net.to_tensor(&x[0], &x[0] + n_samples, input_tensor);
5506 net.forward(input_tensor);
5507
5508 auto& output_tensor = layer<tag1>(net).get_output();
5509
5510 DLIB_TEST(output_tensor.num_samples() == input_tensor.num_samples());
5511 DLIB_TEST(output_tensor.k() == input_tensor.k());
5512 DLIB_TEST(output_tensor.nr() == input_tensor.nr());
5513 DLIB_TEST(output_tensor.nc() == input_tensor.nc());
5514 DLIB_TEST(max(abs(mat(output_tensor) - mat(input_tensor))) < 1e-5);
5515 }
5516
5517// ----------------------------------------------------------------------------------------
5518

Callers 1

run_testsMethod · 0.85

Calls 11

print_spinnerFunction · 0.85
absFunction · 0.85
get_random_gaussianMethod · 0.80
maxFunction · 0.50
matFunction · 0.50
to_tensorMethod · 0.45
forwardMethod · 0.45
num_samplesMethod · 0.45
kMethod · 0.45
nrMethod · 0.45
ncMethod · 0.45

Tested by

no test coverage detected