Skip to content

Commit

Permalink
[Unittest] Add constant DerivativeLossLayer unittest
Browse files Browse the repository at this point in the history
Currently, there is a layersemantics in the NNTrainer Unittest that verifies the behavior of the losslayer
but it does not include the case for the constant DerivativeLossLayer.

By simply filling in the parameters and passing them over, we can perform unit tests on basic operations
so I added this feature.

**Self evaluation:**
1. Build test:	 [X]Passed [ ]Failed [ ]Skipped
2. Run test:	 [X]Passed [ ]Failed [ ]Skipped

Signed-off-by: Donghak PARK <donghak.park@samsung.com>
  • Loading branch information
DonghakPark committed Oct 22, 2024
1 parent 72bdf54 commit 5044f98
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion test/unittest/layers/unittest_layers_loss.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@

#include <gtest/gtest.h>

#include <constant_derivative_loss_layer.h>
#include <cross_entropy_loss_layer.h>
#include <cross_entropy_sigmoid_loss_layer.h>
#include <cross_entropy_softmax_loss_layer.h>
Expand All @@ -34,11 +35,17 @@ auto semantic_loss_mse = LayerSemanticsParamType(
nntrainer::MSELossLayer::type, {},
LayerCreateSetPropertyOptions::AVAILABLE_FROM_APP_CONTEXT, false, 1);

auto semantic_loss_constant_derivative = LayerSemanticsParamType(
nntrainer::createLayer<nntrainer::ConstantDerivativeLossLayer>,
nntrainer::ConstantDerivativeLossLayer::type, {},
LayerCreateSetPropertyOptions::AVAILABLE_FROM_APP_CONTEXT, false, 1);

auto semantic_loss_cross = LayerSemanticsParamType(
nntrainer::createLayer<nntrainer::CrossEntropyLossLayer>,
nntrainer::CrossEntropyLossLayer::type, {}, 0, true, 1);

GTEST_PARAMETER_TEST(LossCross, LayerSemantics,
::testing::Values(semantic_loss_cross, semantic_loss_mse,
semantic_loss_cross_softmax,
semantic_loss_cross_sigmoid));
semantic_loss_cross_sigmoid,
semantic_loss_constant_derivative));

0 comments on commit 5044f98

Please sign in to comment.