Line data Source code
1 : // SPDX-License-Identifier: Apache-2.0
2 : /**
3 : * Copyright (C) 2020 Parichay Kapoor <pk.kapoor@samsung.com>
4 : *
5 : * @file preprocess_flip_layer.h
6 : * @date 20 January 2020
7 : * @see https://github.com/nnstreamer/nntrainer
8 : * @author Parichay Kapoor <pk.kapoor@samsung.com>
9 : * @bug No known bugs except for NYI items
10 : * @brief This is Preprocess Random Flip Layer Class for Neural Network
11 : *
12 : */
13 :
14 : #ifndef __PREPROCESS_FLIP_LAYER_H__
15 : #define __PREPROCESS_FLIP_LAYER_H__
16 : #ifdef __cplusplus
17 :
18 : #include <random>
19 :
20 : #include <common_properties.h>
21 : #include <layer_devel.h>
22 :
23 : namespace nntrainer {
24 :
25 : /**
26 : * @class Preprocess FLip Layer
27 : * @brief Preprocess FLip Layer
28 : */
29 : class PreprocessFlipLayer : public Layer {
30 : public:
31 : /**
32 : * @brief Constructor of Preprocess FLip Layer
33 : */
34 : PreprocessFlipLayer();
35 :
36 : /**
37 : * @brief Destructor of Preprocess FLip Layer
38 : */
39 66 : ~PreprocessFlipLayer() = default;
40 :
41 : /**
42 : * @brief Move constructor of PreprocessLayer.
43 : * @param[in] PreprocessLayer &&
44 : */
45 : PreprocessFlipLayer(PreprocessFlipLayer &&rhs) noexcept = default;
46 :
47 : /**
48 : * @brief Move assignment operator.
49 : * @parma[in] rhs PreprocessLayer to be moved.
50 : */
51 : PreprocessFlipLayer &operator=(PreprocessFlipLayer &&rhs) = default;
52 :
53 : /**
54 : * @copydoc Layer::finalize(InitLayerContext &context)
55 : */
56 : void finalize(InitLayerContext &context) override;
57 :
58 : /**
59 : * @copydoc Layer::forwarding(RunLayerContext &context, bool training)
60 : */
61 : void forwarding(RunLayerContext &context, bool training) override;
62 :
63 : /**
64 : * @copydoc Layer::calcDerivative(RunLayerContext &context)
65 : */
66 : void calcDerivative(RunLayerContext &context) override;
67 :
68 : /**
69 : * @copydoc bool supportBackwarding() const
70 : */
71 2 : bool supportBackwarding() const override { return false; };
72 :
73 : /**
74 : * @copydoc Layer::exportTo(Exporter &exporter, ml::train::ExportMethods
75 : * method)
76 : */
77 : void exportTo(Exporter &exporter,
78 : const ml::train::ExportMethods &method) const override;
79 :
80 : /**
81 : * @copydoc Layer::getType()
82 : */
83 31 : const std::string getType() const override {
84 31 : return PreprocessFlipLayer::type;
85 : };
86 :
87 : /**
88 : * @copydoc Layer::setProperty(const std::vector<std::string> &values)
89 : */
90 : void setProperty(const std::vector<std::string> &values) override;
91 :
92 : static constexpr const char *type = "preprocess_flip";
93 :
94 : private:
95 : std::mt19937 rng; /**< random number generator */
96 : std::uniform_real_distribution<float>
97 : flip_dist; /**< uniform random distribution */
98 : std::tuple<props::FlipDirection> preprocess_flip_props;
99 : };
100 :
101 : } // namespace nntrainer
102 :
103 : #endif /* __cplusplus */
104 : #endif /* __PREPROCESS_FLIP_LAYER_H__ */
|