Enable trainable property to layer
authorhyeonseok lee <hs89.lee@samsung.com>
Tue, 5 Jan 2021 12:03:39 +0000 (21:03 +0900)
committerJijoong Moon <jijoong.moon@samsung.com>
Thu, 21 Jan 2021 01:58:52 +0000 (10:58 +0900)
Set trainable value to false in constructor in activation layer, flatten_layer

Signed-off-by: hyeonseok lee <hs89.lee@samsung.com>
api/ccapi/include/layer.h
nntrainer/layers/activation_layer.h
nntrainer/layers/flatten_layer.h
nntrainer/layers/layer.cpp
nntrainer/utils/parse_util.cpp

index 2cdb2ee..7f8d1f4 100644 (file)
@@ -126,6 +126,7 @@ public:
     modelfile = 25, /** model file for loading config for backbone layer */
     input_layers = 26,
     output_layers = 27,
+    trainable = 28,
     unknown
   };
 
index 1ef5876..daf9a73 100644 (file)
@@ -33,6 +33,7 @@ public:
   template <typename... Args>
   ActivationLayer(ActivationType at = ActivationType::ACT_NONE, Args... args) :
     Layer(args...) {
+    setTrainable(false);
     setActivation(at);
   }
 
index 8d61a04..026eaa3 100644 (file)
@@ -29,7 +29,9 @@ public:
   /**
    * @brief     Constructor of Flatten Layer
    */
-  template <typename... Args> FlattenLayer(Args... args) : Layer(args...) {}
+  template <typename... Args> FlattenLayer(Args... args) : Layer(args...) {
+    setTrainable(false);
+  }
 
   /**
    * @brief     Destructor of Flatten Layer
index 1e7d962..0bfbad5 100644 (file)
@@ -272,6 +272,12 @@ void Layer::setProperty(const PropertyType type, const std::string &value) {
         output_layers.push_back(concat_layers[i]);
     }
     break;
+  case PropertyType::trainable:
+    if (!value.empty()) {
+      status = setBoolean(trainable, value);
+      throw_status(status);
+    }
+    break;
   default:
     std::string msg =
       "[Layer] Unknown Layer Property Key for value " + std::string(value);
index 28d8012..237321d 100644 (file)
@@ -248,7 +248,7 @@ unsigned int parseType(std::string ll, InputType t) {
  * Pooling2DLayer has 12, 13, 14, 15 properties.
  * BatchNormalizationLayer has 0, 1, 5, 6, 7 properties.
  */
-static std::array<std::string, 29> property_string = {
+static std::array<std::string, 30> property_string = {
   "input_shape",
   "normalization",
   "standardization",
@@ -277,6 +277,7 @@ static std::array<std::string, 29> property_string = {
   "modelfile",
   "input_layers",
   "output_layers",
+  "trainable",
   "unknown"};
 
 unsigned int parseLayerProperty(std::string property) {