Class Model
Definition
- Namespace:
- Tizen.MachineLearning.Train
- Assembly:
- Tizen.MachineLearning.Train.dll
- API Level:
- 10
- Feature:
- http://tizen.org/feature/machine_learning.training
Constructs the neural network model
C#Copypublic class Model : IDisposable
- Inheritance
-
Model
Remarks
Use this class to create neural network model. The Model class provides interfaces to construct, complle, run, adding layer and etc with neural networks. If you want to access only internal storage by using this method, you should add privilege %http://tizen.org/privilege/mediastorage. Or, if you want to access only external storage by using this method, you should add privilege %http://tizen.org/privilege/externalstorage. If you want to access both storage, you must add all the privileges.
Constructors
Declaration
C#Copypublic Model()
API Level: 10
Declaration
C#Copypublic Model(string modelConf)
Parameters
Type | Name | Description |
---|---|---|
String | modelConf | The nntrainer model configuration file. |
API Level: 10
Methods
Declaration
C#Copypublic void AddLayer(Layer layer)
Parameters
Type | Name | Description |
---|---|---|
Layer | layer | The instance of Layer class |
Remarks
Use this method 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. Layer is available until the model is released, so Dispose() must never be used.
API Level: 10
Compile(String[])
Compiles and finalizes the neural network model with the hyperparameter.
Declaration
C#Copypublic void Compile(params string[] hyperparameter)
Parameters
Type | Name | Description |
---|---|---|
String[] | hyperparameter |
Remarks
Use this method to initialize neural network model.Various hyperparameter can be set before compile the model. Once compiled, any modification to the properties of model or layers/dataset/optimizer in the model will be restricted. Further, addition of layers or changing the optimizer/dataset of the model will not be permitted. The input format of hyperparameter must be 'key = value' format. Hyperparameter for train complie.
API Level: 10
Declaration
C#Copypublic void Dispose()
API Level: 10
Dispose(Boolean)
Releases any unmanaged resources used by this object including opened handle.
Declaration
C#Copyprotected virtual void Dispose(bool disposing)
Parameters
Type | Name | Description |
---|---|---|
Boolean | disposing | If true, disposes any disposable objects. If false, does not dispose disposable objects. |
API Level: 10
Declaration
C#Copyprotected void Finalize()
API Level: 10
Declaration
C#Copypublic TensorsInfo GetInputTensorsInfo()
Returns
Type | Description |
---|---|
TensorsInfo | TensorsInfo instance |
Remarks
Use this method to get input tensors information of the model. Model must be compiled before calling this method.
API Level: 10
Declaration
C#Copypublic Layer GetLayer(string layerName)
Parameters
Type | Name | Description |
---|---|---|
String | layerName | Name of the already created layer. |
Returns
Type | Description |
---|---|
Layer | layer instance |
Remarks
Use this method to get already created Neural Network Layer. The returned layer must not be deleted as it is owned by the model. layerName can be set by SetProperty method of Layer. Returned layer instance is different with same layerName, but internally the native layer handle is same.
API Level: 10
Declaration
C#Copypublic TensorsInfo GetOutputTensorsInfo()
Returns
Type | Description |
---|---|
TensorsInfo | TensorsInfo instance |
Remarks
Use this method to get output tensors information of the model. Model must be compiled before calling this method.
API Level: 10
Declaration
C#Copypublic string GetSummary(NNTrainerSummaryType verbosity)
Parameters
Type | Name | Description |
---|---|---|
NNTrainerSummaryType | verbosity | Verbose level of the summary. |
Returns
Type | Description |
---|---|
String | On return, a string value. The summary of the current model. Avoid logic to parse and exploit summary if possible. |
API Level: 10
Declaration
C#Copypublic void Load(string filePath, NNTrainerModelFormat format)
Parameters
Type | Name | Description |
---|---|---|
String | filePath | File path to load the file. |
NNTrainerModelFormat | format | Format flag to determine which format should be used to load. |
Remarks
Use this method to load the current model. Format describes various formats in which various selections of the parameters of the models can be loaded. Some formats may load parameters required for training. Some other formats may load model configurations. Unless stated otherwise, loading model configuration requires a freshly constructed model with new Model() without Compile(String[]), loading model parameter requires Compile() to be called upon the model before calling this method. If you want to access only internal storage by using this method, you should add privilege %http://tizen.org/privilege/mediastorage. Or, if you want to access only external storage by using this method, you should add privilege %http://tizen.org/privilege/externalstorage. If you want to access both storage, you must add all the privileges.
API Level: 10
Declaration
C#Copypublic void Run(params string[] hyperparameter)
Parameters
Type | Name | Description |
---|---|---|
String[] | hyperparameter | Hyperparameters for train model. |
Remarks
Use this method to train the compiled neural network model with the passed training hyperparameters. This method will return once the training, along with requested validation and testing, is completed. The input format of hyperparameter must be 'key = value' format.
API Level: 10
Declaration
C#Copypublic void Save(string filePath, NNTrainerModelFormat format)
Parameters
Type | Name | Description |
---|---|---|
String | filePath | File path to save the file. |
NNTrainerModelFormat | format | Format flag to determine which format should be used to save. |
Remarks
Use this method to save the current model. Format describes various formats in which various selections of the parameters of the models can be saved. Some formats may save parameters required for training. Some other formats may save model configurations. Unless stated otherwise, Compile(String[]) has to be called upon the a model before calling this method. Saved ini, if any, is not guaranteed to be identical to the original ini that might have been used to load the model. If you want to access only internal storage by using this method, you should add privilege %http://tizen.org/privilege/mediastorage. Or, if you want to access only external storage by using this method, you should add privilege %http://tizen.org/privilege/externalstorage. If you want to access both storage, you must add all the privileges.
API Level: 10
Declaration
C#Copypublic void SetDataset(Dataset dataset)
Parameters
Type | Name | Description |
---|---|---|
Dataset | dataset | The instance of Dataset class |
Remarks
Use this method to set dataset for running the model. The dataset will provide training, validation and test data for the model. This transfers the ownership of the dataset to the network. No need to destroy the dataset once it is set to a model. Unsets the previously set dataset, if any. The previously set dataset must be freed using Dispose().
API Level: 10
Declaration
C#Copypublic void SetOptimizer(Optimizer optimizer)
Parameters
Type | Name | Description |
---|---|---|
Optimizer | optimizer | The instance of Optimizer class |
Remarks
Use this method to set neural network optimizer. This transfers the ownership of the optimizer to the network. No need to destroy the optimizer if it is added to a model.