#include <nntrainer_error.h>
/**
- * @brief Neural Network Model Configuration with ini file (possitive test )
+ * @brief Neural Network Model Configuration with ini file (positive test)
*/
TEST(nntrainer_NeuralNetwork, setConfig_01_p) {
- int status = ML_ERROR_NONE;
std::string config_file = "./test.ini";
RESET_CONFIG(config_file.c_str());
replaceString("Layers = inputlayer outputlayer",
"Layers = inputlayer outputlayer", config_file, config_str);
nntrainer::NeuralNetwork NN;
- status = NN.setConfig(config_file);
- EXPECT_EQ(status, ML_ERROR_NONE);
+ EXPECT_NO_THROW(NN.setConfig(config_file));
}
/**
- * @brief Neural Network Model Configuration with ini file (negative test )
+ * @brief Neural Network Model Configuration with ini file (negative test)
*/
TEST(nntrainer_NeuralNetwork, setConfig_02_n) {
- int status = ML_ERROR_NONE;
std::string config_file = "../test/not_found.ini";
nntrainer::NeuralNetwork NN;
- status = NN.setConfig(config_file);
- EXPECT_EQ(status, ML_ERROR_INVALID_PARAMETER);
+ EXPECT_THROW(NN.setConfig(config_file), std::invalid_argument);
}
/**
replaceString("Layers = inputlayer outputlayer",
"Layers = inputlayer outputlayer", config_file, config_str);
nntrainer::NeuralNetwork NN;
- status = NN.setConfig(config_file);
- EXPECT_EQ(status, ML_ERROR_NONE);
+ EXPECT_NO_THROW(NN.setConfig(config_file));
+
status = NN.loadFromConfig();
EXPECT_EQ(status, ML_ERROR_NONE);
status = NN.init();
RESET_CONFIG("./test.ini");
replaceString("[Network]", "", "./test.ini", config_str);
nntrainer::NeuralNetwork NN;
- status = NN.setConfig("./test.ini");
- EXPECT_EQ(status, ML_ERROR_NONE);
+ NN.setConfig("./test.ini");
+
status = NN.loadFromConfig();
EXPECT_EQ(status, ML_ERROR_INVALID_PARAMETER);
}
RESET_CONFIG("./test.ini");
replaceString("adam", "aaaadam", "./test.ini", config_str);
nntrainer::NeuralNetwork NN;
- status = NN.setConfig("./test.ini");
- EXPECT_EQ(status, ML_ERROR_NONE);
+ NN.setConfig("./test.ini");
+
status = NN.loadFromConfig();
EXPECT_EQ(status, ML_ERROR_INVALID_PARAMETER);
}
* @brief Neural Network Model initialization
*/
TEST(nntrainer_NeuralNetwork, load_config_03_n) {
- int status = ML_ERROR_NONE;
RESET_CONFIG("./test.ini");
replaceString("Input_Shape = 32:1:1:62720", "Input_Shape = 32:1:1:0",
"./test.ini", config_str);
nntrainer::NeuralNetwork NN;
- status = NN.setConfig("./test.ini");
- EXPECT_EQ(status, ML_ERROR_NONE);
+ NN.setConfig("./test.ini");
+
+ /**< C++ exception with description "[TensorDim] Trying to assign value of 0
+ * to tensor dim" thrown in the test body. */
EXPECT_THROW(NN.loadFromConfig(), std::invalid_argument);
}
RESET_CONFIG("./test.ini");
replaceString("Input_Shape = 32:1:1:62720", "", "./test.ini", config_str);
nntrainer::NeuralNetwork NN;
- status = NN.setConfig("./test.ini");
- EXPECT_EQ(status, ML_ERROR_NONE);
+ NN.setConfig("./test.ini");
+
status = NN.loadFromConfig();
EXPECT_EQ(status, ML_ERROR_NONE);
}
replaceString("Learning_rate = 0.0001", "Learning_rate = -0.0001",
"./test.ini", config_str);
nntrainer::NeuralNetwork NN;
- status = NN.setConfig("./test.ini");
+ NN.setConfig("./test.ini");
+
EXPECT_EQ(status, ML_ERROR_NONE);
status = NN.loadFromConfig();
EXPECT_EQ(status, ML_ERROR_INVALID_PARAMETER);
RESET_CONFIG("./test.ini");
replaceString("TrainData = trainingSet.dat", "", "./test.ini", config_str);
nntrainer::NeuralNetwork NN;
- status = NN.setConfig("./test.ini");
+ NN.setConfig("./test.ini");
+
EXPECT_EQ(status, ML_ERROR_NONE);
status = NN.loadFromConfig();
EXPECT_EQ(status, ML_ERROR_INVALID_PARAMETER);
replaceString("bias_init_zero = true", "Bias_Init_Zero = false", "./test.ini",
config_str);
nntrainer::NeuralNetwork NN;
- status = NN.setConfig("./test.ini");
+ NN.setConfig("./test.ini");
+
EXPECT_EQ(status, ML_ERROR_NONE);
status = NN.loadFromConfig();
EXPECT_EQ(status, ML_ERROR_NONE);
RESET_CONFIG("./test.ini");
replaceString("TestData = testSet.dat", "", "./test.ini", config_str);
nntrainer::NeuralNetwork NN;
- status = NN.setConfig("./test.ini");
- EXPECT_EQ(status, ML_ERROR_NONE);
+ NN.setConfig("./test.ini");
+
status = NN.loadFromConfig();
EXPECT_EQ(status, ML_ERROR_NONE);
status = NN.init();
RESET_CONFIG("./test.ini");
replaceString("LabelData = label.dat", "", "./test.ini", config_str);
nntrainer::NeuralNetwork NN;
- status = NN.setConfig("./test.ini");
- EXPECT_EQ(status, ML_ERROR_NONE);
+ NN.setConfig("./test.ini");
+
status = NN.loadFromConfig();
EXPECT_EQ(status, ML_ERROR_INVALID_PARAMETER);
}
RESET_CONFIG(config_file.c_str());
replaceString("ValidData = valSet.dat", "", config_file, config_str);
nntrainer::NeuralNetwork NN;
- status = NN.setConfig(config_file);
- EXPECT_EQ(status, ML_ERROR_NONE);
+ NN.setConfig(config_file);
+
status = NN.loadFromConfig();
EXPECT_EQ(status, ML_ERROR_NONE);
status = NN.init();
RESET_CONFIG(config_file.c_str());
replaceString("ValidData = valSet.dat", "", config_file, config_str2);
nntrainer::NeuralNetwork NN;
- status = NN.setConfig(config_file);
- EXPECT_EQ(status, ML_ERROR_NONE);
+ NN.setConfig(config_file);
status = NN.loadFromConfig();
EXPECT_EQ(status, ML_ERROR_NONE);
status = NN.init();
}
/**
- * @brief Flatten Layer
+ * @brief Conv2D Layer
*/
TEST(nntrainer_Conv2DLayer, initialize_02_p) {
int status = ML_ERROR_NONE;
RESET_CONFIG(config_file.c_str());
replaceString("flatten = false", "flatten = true", config_file, config_str2);
nntrainer::NeuralNetwork NN;
- status = NN.setConfig(config_file);
- EXPECT_EQ(status, ML_ERROR_NONE);
+ NN.setConfig(config_file);
status = NN.loadFromConfig();
EXPECT_EQ(status, ML_ERROR_NONE);
status = NN.init();
RESET_CONFIG(config_file.c_str());
replaceString("flatten = false", "flatten = true", config_file, config_str2);
nntrainer::NeuralNetwork NN;
- status = NN.setConfig(config_file);
- EXPECT_EQ(status, ML_ERROR_NONE);
+ NN.setConfig(config_file);
status = NN.loadFromConfig();
EXPECT_EQ(status, ML_ERROR_NONE);
status = NN.init();