MachineIntelligenceCore:NeuralNets
 All Classes Namespaces Files Functions Variables Enumerations Enumerator Friends Macros
LossTests.hpp
Go to the documentation of this file.
1 
25 #ifndef LOSSTESTS_HPP_
26 #define LOSSTESTS_HPP_
27 
28 
29 #include <gtest/gtest.h>
30 
31 // Redefine word "public" so every class field/method will be accessible for tests.
32 #define private public
33 #include "Loss.hpp"
34 
35 
40 class Vectors4x1Float : public ::testing::Test {
41 public:
42  // Constructor. Sets layer size.
44  target_y = MAKE_MATRIX_PTR(float, 4, 1);
45  predicted_y = MAKE_MATRIX_PTR(float, 4, 1);
46  }
47 
48 protected:
49  // Sets values.
50  virtual void SetUp() {
51  (*target_y) << 2.0, 3.0, 4.0, 5.0;
52  (*predicted_y) << 1.0, 2.0, 3.0, 4.0;
53  }
54 
55 private:
56  // Target y values.
57  mic::types::MatrixPtr<float> target_y;
58 
59  // Predicted y values.
60  mic::types::MatrixPtr<float> predicted_y;
61 };
62 
67 class Vectors4x1Float2 : public ::testing::Test {
68 public:
69  // Constructor. Sets layer size.
71  target_y = MAKE_MATRIX_PTR(float, 4,1);
72  predicted_y1 = MAKE_MATRIX_PTR(float, 4, 1);
73  predicted_y2 = MAKE_MATRIX_PTR(float, 4, 1);
74  }
75 
76 protected:
77  // Sets values.
78  virtual void SetUp() {
79  (*target_y) << .4, .1, .25, .25;
80  (*predicted_y1) << .25, .25, .25, .25;
81  (*predicted_y2) << .4, .1, .1, .4;
82  }
83 
84 private:
85  // Target y values.
86  mic::types::MatrixPtr<float> target_y;
87 
88  // Predicted y values 1.
89  mic::types::MatrixPtr<float> predicted_y1;
90  // Predicted y values 2.
91  mic::types::MatrixPtr<float> predicted_y2;
92 };
93 
94 
99 class Vectors3x2Float : public ::testing::Test {
100 public:
101  // Constructor. Sets layer size.
103  target_y = MAKE_MATRIX_PTR(float, 3, 2);
104  predicted_y = MAKE_MATRIX_PTR(float, 3, 2);
105  }
106 
107 protected:
108  // Sets values.
109  virtual void SetUp() {
110  (*target_y) << 0.1, 0.2, 0.3, 0.5, 0.6, 0.1;
111  (*predicted_y) << 0.2, 0.2, 0.4, 0.4, 0.5, 0.6;
112  }
113 
114 private:
115  // Target y values.
116  mic::types::MatrixPtr<float> target_y;
117 
118  // Predicted y values.
119  mic::types::MatrixPtr<float> predicted_y;
120 };
121 
122 
123 #endif /* LOSSTESTS_HPP_ */
mic::types::MatrixPtr< float > predicted_y
Definition: LossTests.hpp:60
Test Fixture - two predictions of size 4x1, floats.
Definition: LossTests.hpp:67
Test Fixture - two vectors of size 4x1, floats.
Definition: LossTests.hpp:40
mic::types::MatrixPtr< float > target_y
Definition: LossTests.hpp:116
mic::types::MatrixPtr< float > target_y
Definition: LossTests.hpp:57
mic::types::MatrixPtr< float > predicted_y1
Definition: LossTests.hpp:89
virtual void SetUp()
Definition: LossTests.hpp:78
Test Fixture - two vectors of size 3x2, floats.
Definition: LossTests.hpp:99
mic::types::MatrixPtr< float > predicted_y
Definition: LossTests.hpp:119
mic::types::MatrixPtr< float > target_y
Definition: LossTests.hpp:86
mic::types::MatrixPtr< float > predicted_y2
Definition: LossTests.hpp:91
virtual void SetUp()
Definition: LossTests.hpp:109
virtual void SetUp()
Definition: LossTests.hpp:50