fix style error
This commit is contained in:
@@ -121,13 +121,9 @@ Copyright:
|
||||
Copyright 2019, Khizir Siddiqui <khizirsiddiqui@gmail.com>
|
||||
Copyright 2019, Tejasvi Tomar <tstomar@outlook.com>
|
||||
Copyright 2019, Jai Agarwal <jai.bhageria@gmail.com>
|
||||
<<<<<<< HEAD
|
||||
Copyright 2019, Ziyang Jiang <zij004@alumni.stanford.edu>
|
||||
Copyright 2019, Rohit Kartik <rohit.audrey@gmail.com>
|
||||
Copyright 2019, Aditya Viki <adityaviki01@gmail.com>
|
||||
=======
|
||||
Copyright 2019, Kartik Dutt <kartikdutt@live.in>
|
||||
>>>>>>> Added Seprate test case and modified same padding
|
||||
|
||||
License: BSD-3-clause
|
||||
All rights reserved.
|
||||
|
||||
@@ -448,8 +448,10 @@ void TransposedConvolution<
|
||||
* K=Kernel Size
|
||||
* P=Padding
|
||||
*/
|
||||
size_t totalPadWidth = (strideWidth - 1) * inputWidth + kernelWidth - strideWidth;
|
||||
size_t totalPadHeight = (strideHeight - 1) * inputHeight + kernelHeight - strideHeight;
|
||||
size_t totalPadWidth = (strideWidth - 1) * inputWidth + kernelWidth - \
|
||||
strideWidth;
|
||||
size_t totalPadHeight = (strideHeight - 1) * inputHeight + kernelHeight - \
|
||||
strideHeight;
|
||||
padWidth = totalPadWidth / 2 + totalPadWidth & 1;
|
||||
padHeight = totalPadHeight / 2 + totalPadHeight & 1;
|
||||
// If Padding is negative throw a fatal error.
|
||||
|
||||
@@ -2960,5 +2960,52 @@ BOOST_AUTO_TEST_CASE(TransposedConvolutionLayerPaddingTest)
|
||||
module2.Forward(std::move(input), std::move(output));
|
||||
// Value calculated using torch.nn.functional.conv_transpose2d().
|
||||
BOOST_REQUIRE_EQUAL(arma::accu(output), 120.0);
|
||||
|
||||
// Test for same padding type.
|
||||
TransposedConvolution<> module3(1, 1, 3, 3, 2, 2, 0, 0, 3, 3, 3, 3, "SAME");
|
||||
// Test the forward function.
|
||||
input = arma::linspace<arma::colvec>(0, 8, 9);
|
||||
module3.Parameters() = arma::mat(9 + 1, 1, arma::fill::zeros);
|
||||
module3.Parameters()(0) = 8.0;
|
||||
module3.Parameters()(2) = 6.0;
|
||||
module3.Parameters()(4) = 2.0;
|
||||
module3.Parameters()(8) = 4.0;
|
||||
module3.Reset();
|
||||
module3.Forward(std::move(input), std::move(output));
|
||||
// Value calculated using torch.nn.functional.conv_transpose2d().
|
||||
BOOST_REQUIRE_EQUAL(arma::accu(output), 606.0);
|
||||
|
||||
// Output shape should equal input.
|
||||
TransposedConvolution<> module4(1, 1, 3, 3, 1, 1, 2, 2, 5, 5, 5, 5, "SAME");
|
||||
// Test the forward function.
|
||||
input = arma::linspace<arma::colvec>(0, 24, 25);
|
||||
module4.Parameters() = arma::mat(9 + 1, 1, arma::fill::zeros);
|
||||
module4.Reset();
|
||||
module4.Forward(std::move(input), std::move(output));
|
||||
BOOST_REQUIRE_EQUAL(arma::accu(output), 0);
|
||||
BOOST_REQUIRE_EQUAL(output.n_rows, input.n_rows);
|
||||
BOOST_REQUIRE_EQUAL(output.n_cols, input.n_cols);
|
||||
|
||||
TransposedConvolution<> module5(1, 1, 3, 3, 2, 2, 0, 0, 2, 2, 2, 2, "SAME");
|
||||
// Test the forward function.
|
||||
input = arma::linspace<arma::colvec>(0, 3, 4);
|
||||
module5.Parameters() = arma::mat(25 + 1, 1, arma::fill::zeros);
|
||||
module5.Reset();
|
||||
module5.Forward(std::move(input), std::move(output));
|
||||
// Value calculated using torch.nn.functional.conv_transpose2d()
|
||||
BOOST_REQUIRE_EQUAL(arma::accu(output), 0);
|
||||
BOOST_REQUIRE_EQUAL(output.n_rows, input.n_rows);
|
||||
BOOST_REQUIRE_EQUAL(output.n_cols, input.n_cols);
|
||||
|
||||
TransposedConvolution<> module6(1, 1, 4, 4, 1, 1, 1, 1, 5, 5, 5, 5, "SAME");
|
||||
// Test the forward function.
|
||||
input = arma::linspace<arma::colvec>(0, 24, 25);
|
||||
module6.Parameters() = arma::mat(16 + 1, 1, arma::fill::zeros);
|
||||
module6.Reset();
|
||||
module6.Forward(std::move(input), std::move(output));
|
||||
// Value calculated using torch.nn.functional.conv_transpose2d()
|
||||
BOOST_REQUIRE_EQUAL(arma::accu(output), 0);
|
||||
BOOST_REQUIRE_EQUAL(output.n_rows, input.n_rows);
|
||||
BOOST_REQUIRE_EQUAL(output.n_cols, input.n_cols);
|
||||
}
|
||||
BOOST_AUTO_TEST_SUITE_END();
|
||||
|
||||
Reference in New Issue
Block a user