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 constant_deriv_loss_layer.h
6 : * @date 05 Oct 2021
7 : * @brief This patch contains constant derivative loss implementation
8 : * @note This is special type of loss to feed an arbitrary derivative value to
9 : * the last layer.
10 : * @see https://github.com/nnstreamer/nntrainer
11 : * @author Jihoon Lee <jhoon.it.lee@samsung.com>
12 : * @bug No known bugs except for NYI items
13 : */
14 : #ifndef __CONSTANT_DERIVATIVE_LOSS_LAYER_H__
15 : #define __CONSTANT_DERIVATIVE_LOSS_LAYER_H__
16 : #ifdef __cplusplus
17 :
18 : #include <loss_layer.h>
19 :
20 : namespace nntrainer {
21 :
22 : /**
23 : * @class ConstantDerivativeLossLayer
24 : * @brief Constant Loss Layer
25 : */
26 : class ConstantDerivativeLossLayer final : public LossLayer {
27 : public:
28 : /**
29 : * @brief Constructor of Constant Loss Layer
30 : */
31 : ConstantDerivativeLossLayer();
32 :
33 : /**
34 : * @brief Destructor of MSE Loss Layer
35 : */
36 : ~ConstantDerivativeLossLayer();
37 :
38 : /**
39 : * @copydoc Layer::setProperty(const std::vector<std::string> &values)
40 : */
41 : void setProperty(const std::vector<std::string> &values) override;
42 :
43 : /**
44 : * @copydoc Layer::forwarding(RunLayerContext &context, bool training)
45 : */
46 : void forwarding(RunLayerContext &context, bool training) override;
47 :
48 : /**
49 : * @copydoc Layer::calcDerivative(RunLayerContext &context)
50 : */
51 : void calcDerivative(RunLayerContext &context) override;
52 :
53 : /**
54 : * @copydoc Layer::getType()
55 : */
56 21 : const std::string getType() const override {
57 21 : return ConstantDerivativeLossLayer::type;
58 : };
59 :
60 : static constexpr const char *type = "constant_derivative";
61 : };
62 : } // namespace nntrainer
63 :
64 : #endif /* __cplusplus */
65 :
66 : #endif // __CONSTANT_DERIVATIVE_LOSS_LAYER_H__
|