[DllImport(Libraries.Nntrainer, EntryPoint = "ml_train_model_save")]
public static extern NNTrainerError Save(IntPtr modelHandle, string filePath, NNTrainerModelFormat format);
- /* int ml_train_model_load(ml_train_model_h model, const char *file_path, ml_train_model_format_e format); */
+ /* int ml_train_model_load(ml_train_model_h model, const char *file_path, ml_train_model_format_e format) */
[DllImport(Libraries.Nntrainer, EntryPoint = "ml_train_model_load")]
public static extern NNTrainerError Load(IntPtr modelHandle, string filePath, NNTrainerModelFormat format);
+ /* int ml_train_model_add_layer(ml_train_model_h model, ml_train_layer_h layer) */
+ [DllImport(Libraries.Nntrainer, EntryPoint = "ml_train_model_add_layer")]
+ public static extern NNTrainerError AddLayer(IntPtr modelHandle, IntPtr layerHandle);
+
}
}
{
NNTrainerError ret = Interop.Model.Construct(out handle);
NNTrainer.CheckException(ret, "Failed to create model instance");
+ Log.Info(NNTrainer.Tag, "Created Model");
}
/// <summary>
{
if (string.IsNullOrEmpty(modelConf))
NNTrainer.CheckException(NNTrainerError.InvalidParameter, "modelConf is null");
- Log.Info(NNTrainer.Tag, "Conf path: "+ modelConf);
+
NNTrainerError ret = Interop.Model.ConstructWithConf(modelConf, out handle);
NNTrainer.CheckException(ret, "Failed to create model instance with modelConf");
+ Log.Info(NNTrainer.Tag, "Created Model with Conf path: "+ modelConf);
}
/// <summary>
/// Destructor of Model
NNTrainerError ret = Interop.Model.Load(handle, filePath, format);
NNTrainer.CheckException(ret, "Failed to load model to path");
}
+
+ /// <summary>
+ /// Adds layer in neural network model.
+ /// </summary>
+ /// <remarks>
+ /// Use this function to add a layer to the model. The layer is added to
+ /// the end of the existing layers in the model. This transfers the
+ /// ownership of the layer to the network. No need to destroy the layer once it
+ /// is added to a model.
+ /// </remarks>
+ /// <param name="layer"> The instance of Layer class </param>
+ /// <since_tizen> 10 </since_tizen>
+ public void AddLayer(Layer layer)
+ {
+ if (layer == null)
+ NNTrainer.CheckException(NNTrainerError.InvalidParameter, "layer instance is null");
+ NNTrainerError ret = Interop.Model.AddLayer(handle, layer.GetHandle());
+ NNTrainer.CheckException(ret, "Failed to compile model");
+ }
}
}