25 #ifndef LINEARLAYERTESTS_HPP_
26 #define LINEARLAYERTESTS_HPP_
28 #include <gtest/gtest.h>
31 #define private public
32 #define protected public
36 namespace mic {
namespace neural_nets {
namespace unit_tests {
83 const_x = MAKE_MATRIX_PTR(
float, 2, 1);
84 const_dy = MAKE_MATRIX_PTR(
float, 3, 1);
85 target_y = MAKE_MATRIX_PTR(
float, 3, 1);
91 (*
layer.
p[
"W"]) << 1, 2, 3, 5, 6, 9;
92 (*
layer.
p[
"b"]) << -3, -2, -1;
96 (*const_dy) << -1, -2, 1;
98 (*target_y) << -1, -2, 1;
134 const_x = MAKE_MATRIX_PTR(
double, 2, 1);
135 const_dy = MAKE_MATRIX_PTR(
double, 3, 1);
136 target_y = MAKE_MATRIX_PTR(
double, 3, 1);
142 (*
layer.
p[
"W"]) << 1, 2, 3, 5, 6, 9;
143 (*
layer.
p[
"b"]) << -3, -2, -1;
147 (*const_dy) << -1, -2, 1;
149 (*target_y) << -1, -2, 1;
193 std::random_device rd;
194 std::mt19937 mt(rd());
198 std::uniform_real_distribution<double> distW(-range, range);
200 (*
layer.
p[
"W"])[i] = (double)distW(rd);
203 std::uniform_real_distribution<double> distb(-5.0, 5.0);
205 (*
layer.
p[
"b"])[row] = (double)distb(rd);
208 std::uniform_real_distribution<double> distxy(-5.0, 5.0);
210 (*
const_x)[i] = (double)distxy(rd);
213 (*
target_y)[i] = (double)distxy(rd);
mic::neural_nets::loss::SquaredErrorLoss< double > loss
Test Fixture - layer of size 5x2, floats.
mic::neural_nets::loss::SquaredErrorLoss< double > loss
size_t inputSize()
Returns size (length) of inputs.
mic::mlnn::fully_connected::Linear< float > layer
mic::mlnn::fully_connected::Linear< double > layer
mic::types::MatrixPtr< float > target_y
mic::types::MatrixPtr< float > const_x
Test Fixture - layer of size 1x1, floats, sets W[0] = 1.0 and b[0] = 1.0.
size_t outputSize()
Returns size (length) of outputs.
Test Fixture - layer of size 50x100, doubles, randomly sets all internal and external values required...
mic::mlnn::fully_connected::Linear< float > layer
mic::types::MatrixPtr< double > const_x
Test Fixture - layer of size 2x3, floats, sets all internal and external values.
mic::types::MatrixPtr< double > const_x
mic::types::MatrixPtr< double > target_y
mic::types::MatrixArray< eT > s
States - contains input [x] and output [y] matrices.
mic::types::MatrixArray< eT > g
Gradients - contains input [x] and output [y] matrices.
mic::types::MatrixPtr< double > const_dy
mic::mlnn::fully_connected::Linear< double > layer
mic::types::MatrixPtr< double > target_y
mic::types::MatrixPtr< float > const_dy
mic::neural_nets::loss::SquaredErrorLoss< float > loss
Test Fixture - layer of size 2x3, doubles, sets all internal and external values. ...
mic::mlnn::fully_connected::Linear< float > layer
mic::types::MatrixArray< eT > p
Parameters - parameters of the layer, to be used by the derived classes.