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 sgd.h
6 : * @date 6 October 2020
7 : * @see https://github.com/nnstreamer/nntrainer
8 : * @author Jijoong Moon <jijoong.moon@samsung.com>
9 : * @author Parichay Kapoor <pk.kapoor@samsung.com>
10 : * @bug No known bugs except for NYI items
11 : * @brief This is the SGD optimizer.
12 : */
13 : #ifndef __SGD_H__
14 : #define __SGD_H__
15 : #ifdef __cplusplus
16 :
17 : #include <optimizer_devel.h>
18 :
19 : namespace nntrainer {
20 :
21 : /**
22 : * @class SGD optimizer class
23 : * @brief Stochastic Gradient Descent optimizer class
24 : */
25 : class SGD : public Optimizer {
26 : public:
27 : /**
28 : * @brief Construct a new SGD object
29 : *
30 : */
31 549 : SGD() {}
32 :
33 : /**
34 : * @copydoc Optimizer::getDefaultLearningRate()
35 : *
36 : */
37 545 : double getDefaultLearningRate() const override { return 0.0001; }
38 :
39 : /**
40 : * @copydoc applyGradient(RunOptimizerContext &context)
41 : */
42 : void applyGradient(RunOptimizerContext &context) override;
43 :
44 : /**
45 : * @copydoc Optimizer::getType()
46 : */
47 15748 : const std::string getType() const override { return SGD::type; }
48 :
49 : /**
50 : * @copydoc Optimizer::getOptimizerVariableDim(const TensorDim &dim)
51 : */
52 : std::vector<TensorDim>
53 3504 : getOptimizerVariableDim(const TensorDim &dim) override {
54 3504 : return {};
55 : }
56 :
57 : static constexpr const char *type = "sgd";
58 : };
59 : } /* namespace nntrainer */
60 :
61 : #endif /* __cplusplus */
62 : #endif /* __SGD_H__ */
|