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 model_common_properties.cpp
6 : * @date 27 Aug 2021
7 : * @brief This file contains common properties for model
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 : #include <model_common_properties.h>
14 :
15 : #include <nntrainer_log.h>
16 : #include <util_func.h>
17 :
18 : namespace nntrainer::props {
19 836 : Epochs::Epochs(unsigned int value) { set(value); }
20 :
21 466 : bool LossType::isValid(const std::string &value) const {
22 466 : ml_logw("Model loss property is deprecated, use loss layer directly instead");
23 932 : return istrequal(value, "cross") || istrequal(value, "mse") ||
24 933 : istrequal(value, "kld");
25 : }
26 :
27 836 : TrainingBatchSize::TrainingBatchSize(unsigned int value) { set(value); }
28 :
29 836 : ContinueTrain::ContinueTrain(bool value) { set(value); }
30 :
31 836 : MemoryOptimization::MemoryOptimization(bool value) { set(value); }
32 :
33 836 : Fsu::Fsu(bool value) { set(value); }
34 :
35 836 : FsuPath::FsuPath(const std::string &value) { set(value); }
36 :
37 836 : FsuLookahead::FsuLookahead(const unsigned int &value) { set(value); }
38 836 : ModelTensorDataType::ModelTensorDataType(ModelTensorDataTypeInfo::Enum value) {
39 836 : set(value);
40 836 : }
41 836 : LossScale::LossScale(float value) { set(value); }
42 :
43 1075 : bool LossScale::isValid(const float &value) const {
44 1075 : bool is_valid = (std::fpclassify(value) != FP_ZERO);
45 1075 : if (!is_valid)
46 0 : ml_loge("Loss scale cannot be 0");
47 1075 : return is_valid;
48 : }
49 :
50 : } // namespace nntrainer::props
|