Line data Source code
1 : // SPDX-License-Identifier: Apache-2.0
2 : /**
3 : * Copyright (C) 2021 Jihoon Lee <jhoon.it.lee@samsung.com>
4 : *
5 : * @file kld_loss_layer.h
6 : * @date 25 November 2021
7 : * @brief KLD (Kullback-Leibler Divergence) loss implementation
8 : * @see https://github.com/nnstreamer/nntrainer
9 : * @author Jihoon Lee <jhoon.it.lee@samsung.com>
10 : * @bug No known bugs except for NYI items
11 : *
12 : */
13 : #ifndef __KLD_LOSS_LAYER_H__
14 : #define __KLD_LOSS_LAYER_H__
15 :
16 : #ifdef __cplusplus
17 :
18 : #include <loss_layer.h>
19 : #include <string>
20 : #include <vector>
21 :
22 : namespace nntrainer {
23 :
24 : /**
25 : * @class KLD (Kullback-Leibler Divergence) Loss layer
26 : * @brief kld loss layer
27 : */
28 : class KLDLossLayer : public LossLayer {
29 : public:
30 : /**
31 : * @brief Constructor of Constant Loss Layer
32 : */
33 19 : KLDLossLayer() : LossLayer() {}
34 :
35 : /**
36 : * @brief Destructor of MSE Loss Layer
37 : */
38 19 : ~KLDLossLayer() = default;
39 :
40 : /**
41 : * @copydoc Layer::forwarding(RunLayerContext &context, bool training)
42 : */
43 : void forwarding(RunLayerContext &context, bool training) override;
44 :
45 : /**
46 : * @copydoc Layer::calcDerivative(RunLayerContext &context)
47 : */
48 : void calcDerivative(RunLayerContext &context) override;
49 :
50 : /**
51 : * @copydoc Layer::getType()
52 : */
53 22 : const std::string getType() const override { return KLDLossLayer::type; }
54 :
55 : static constexpr const char *type = "kld";
56 : };
57 : } // namespace nntrainer
58 :
59 : #endif /* __cplusplus */
60 : #endif // __KLD_LOSS_LAYER_H__
|