[MachineLearning.Train] Add SetProperty method to Layer class
authorHyunil <hyunil46.park@samsung.com>
Mon, 13 Jun 2022 09:37:00 +0000 (18:37 +0900)
committerJijoong Moon <jijoong.moon@samsung.com>
Tue, 23 Aug 2022 05:50:26 +0000 (14:50 +0900)
- Add SetProperty(params string[] property) to Layer
- Add ml_train_layer_set_property_with_single_param() to interop
- Fix bug about checking params string[]
- Change GetSummaryUtil to GetSummary

Signed-off-by: Hyunil <hyunil46.park@samsung.com>
src/Tizen.MachineLearning.Train/Interop/Interop.Layer.cs
src/Tizen.MachineLearning.Train/Interop/Interop.Model.cs
src/Tizen.MachineLearning.Train/Tizen.MachineLearning.Train/Layer.cs
src/Tizen.MachineLearning.Train/Tizen.MachineLearning.Train/Model.cs

index 20395f8..53affea 100644 (file)
@@ -29,5 +29,9 @@ internal static partial class Interop
         /* int ml_train_layer_destroy(ml_train_layer_h layer) */
         [DllImport(Libraries.Nntrainer, EntryPoint = "ml_train_layer_destroy")]
         public static extern NNTrainerError Destroy(IntPtr layerHandle);
+
+        /* int ml_train_layer_set_property_with_single_param(ml_train_layer_h layer, const char *single_param) */
+        [DllImport(Libraries.Nntrainer, EntryPoint = "ml_train_layer_set_property_with_single_param")]
+        public static extern NNTrainerError SetProperty(IntPtr layerHandle, string propertyParams);
     }
 }
\ No newline at end of file
index 08d0f0f..9487860 100644 (file)
@@ -44,7 +44,7 @@ internal static partial class Interop
 
         /* int ml_train_model_get_summary(ml_train_model_h model, ml_train_summary_type_e verbosity, char **summary) */
         [DllImport(Libraries.Nntrainer, EntryPoint = "ml_train_model_get_summary")]
-        public static extern NNTrainerError GetSummaryUtil(IntPtr modelHandle, NNTrainerSummaryType verbosity, out string summary);
+        public static extern NNTrainerError GetSummary(IntPtr modelHandle, NNTrainerSummaryType verbosity, out string summary);
 
         /* int ml_train_model_save(ml_train_model_h model, const char *file_path, ml_train_model_format_e format) */
         [DllImport(Libraries.Nntrainer, EntryPoint = "ml_train_model_save")]
index c4a903c..9979f38 100644 (file)
@@ -90,5 +90,26 @@ namespace Tizen.MachineLearning.Train
             }
             disposed = true;
         }
+
+        /// <summary>
+        /// Sets the neural network layer Property.
+        /// </summary>
+        /// <remarks>
+        /// Use this function to set neural network layer Property.
+        /// </remarks>
+        /// <param name="property">property for layer.</param>
+        /// <since_tizen> 10 </since_tizen>
+        public void SetProperty(params string[] property)
+        {
+            string propertyParams = null;
+
+            if (property.Length > 0) {
+                propertyParams = string.Join("|", property);
+                Log.Info(NNTrainer.Tag, "Set property:"+ propertyParams);
+            }
+
+            NNTrainerError ret = Interop.Layer.SetProperty(handle, propertyParams);
+            NNTrainer.CheckException(ret, "Failed to set property");
+        }
     } 
 }
index b22ff62..8f656b0 100644 (file)
@@ -121,7 +121,7 @@ namespace Tizen.MachineLearning.Train
         {
             string compileParams = null;
 
-            if (hyperparameter != null) {
+            if (hyperparameter.Length > 0) {
                 compileParams = string.Join("|", hyperparameter);
                 Log.Info(NNTrainer.Tag, "Compile hyperparameter:"+ compileParams);
             }
@@ -144,7 +144,7 @@ namespace Tizen.MachineLearning.Train
         {
             string runParams = null;
 
-            if (hyperparameter != null) {
+            if (hyperparameter.Length > 0) {
                 runParams = string.Join("|", hyperparameter);
                 Log.Info(NNTrainer.Tag, "Run hyperparameter:"+ runParams);
             }
@@ -162,9 +162,9 @@ namespace Tizen.MachineLearning.Train
         /// <param name="verbosity">Verbose level of the summary.</param>
         /// <param name="retSummary">On return, a string value. The summary of the current model. Avoid logic to parse and exploit summary if possible.</param>
         /// <since_tizen> 10 </since_tizen>
-        public void GetSummaryUtil(NNTrainerSummaryType verbosity, out string retSummary)
+        public void GetSummary(NNTrainerSummaryType verbosity, out string retSummary)
         {
-            NNTrainerError ret = Interop.Model.GetSummaryUtil(handle, verbosity, out string summary);
+            NNTrainerError ret = Interop.Model.GetSummary(handle, verbosity, out string summary);
             NNTrainer.CheckException(ret, "Failed to get summary");
 
             retSummary = summary;