Class Model
Definition
- Assembly:
- Tizen.MachineLearning.Train.dll
Constructs the neural network model
C#Copypublic class Model : IDisposable
- Inheritance
-
objectModel
- Implements
-
System.IDisposable
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()
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.
Exceptions
| Type | Condition |
|---|---|
| System.NotSupportedException | Thrown when the feature is not supported. |
| System.ArgumentException | Thrown when the method failed due to an invalid parameter. |
| System.UnauthorizedAccessException | Thrown when the application does not have the required privilege. |
| System.InvalidOperationException | Thrown when the method failed due to the wrong pipeline description or internal error. |
Declaration
C#Copypublic Model(string modelConf)
Parameters
| Type | Name | Description |
|---|---|---|
| string | modelConf | The nntrainer model configuration file. |
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.
Exceptions
| Type | Condition |
|---|---|
| System.NotSupportedException | Thrown when the feature is not supported. |
| System.ArgumentException | Thrown when the method failed due to an invalid parameter. |
| System.UnauthorizedAccessException | Thrown when the application does not have the required privilege. |
| System.InvalidOperationException | Thrown when the method failed due to the wrong pipeline description or internal error. |
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.
Exceptions
| Type | Condition |
|---|---|
| System.NotSupportedException | Thrown when the feature is not supported. |
| System.ArgumentException | Thrown when the method failed due to an invalid parameter. |
| System.UnauthorizedAccessException | Thrown when the application does not have the required privilege. |
| System.InvalidOperationException | Thrown when the method failed due to the wrong pipeline description or internal error. |
Compile(params 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.Exceptions
| Type | Condition |
|---|---|
| System.NotSupportedException | Thrown when the feature is not supported. |
| System.ArgumentException | Thrown when the method failed due to an invalid parameter. |
| System.UnauthorizedAccessException | Thrown when the application does not have the required privilege. |
| System.InvalidOperationException | Thrown when the method failed due to the wrong pipeline description or internal error. |
Declaration
C#Copypublic void Dispose()
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.
Exceptions
| Type | Condition |
|---|---|
| System.NotSupportedException | Thrown when the feature is not supported. |
| System.ArgumentException | Thrown when the method failed due to an invalid parameter. |
| System.UnauthorizedAccessException | Thrown when the application does not have the required privilege. |
| System.InvalidOperationException | Thrown when the method failed due to the wrong pipeline description or internal error. |
Dispose(bool)
Releases any unmanaged resources used by this object including opened handle.
Declaration
C#Copyprotected virtual void Dispose(bool disposing)
Parameters
| Type | Name | Description |
|---|---|---|
| bool | disposing | If true, disposes any disposable objects. If false, does not dispose disposable objects. |
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.
Exceptions
| Type | Condition |
|---|---|
| System.NotSupportedException | Thrown when the feature is not supported. |
| System.ArgumentException | Thrown when the method failed due to an invalid parameter. |
| System.UnauthorizedAccessException | Thrown when the application does not have the required privilege. |
| System.InvalidOperationException | Thrown when the method failed due to the wrong pipeline description or internal error. |
Declaration
C#Copyprotected ~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.
Exceptions
| Type | Condition |
|---|---|
| System.NotSupportedException | Thrown when the feature is not supported. |
| System.ArgumentException | Thrown when the method failed due to an invalid parameter. |
| System.UnauthorizedAccessException | Thrown when the application does not have the required privilege. |
| System.InvalidOperationException | Thrown when the method failed due to the wrong pipeline description or internal error. |
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.
Exceptions
| Type | Condition |
|---|---|
| System.NotSupportedException | Thrown when the feature is not supported. |
| System.ArgumentException | Thrown when the method failed due to an invalid parameter. |
| System.UnauthorizedAccessException | Thrown when the application does not have the required privilege. |
| System.InvalidOperationException | Thrown when the method failed due to the wrong pipeline description or internal error. |
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.
Exceptions
| Type | Condition |
|---|---|
| System.NotSupportedException | Thrown when the feature is not supported. |
| System.ArgumentException | Thrown when the method failed due to an invalid parameter. |
| System.UnauthorizedAccessException | Thrown when the application does not have the required privilege. |
| System.InvalidOperationException | Thrown when the method failed due to the wrong pipeline description or internal error. |
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.
Exceptions
| Type | Condition |
|---|---|
| System.NotSupportedException | Thrown when the feature is not supported. |
| System.ArgumentException | Thrown when the method failed due to an invalid parameter. |
| System.UnauthorizedAccessException | Thrown when the application does not have the required privilege. |
| System.InvalidOperationException | Thrown when the method failed due to the wrong pipeline description or internal error. |
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. |
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.
Exceptions
| Type | Condition |
|---|---|
| System.NotSupportedException | Thrown when the feature is not supported. |
| System.ArgumentException | Thrown when the method failed due to an invalid parameter. |
| System.UnauthorizedAccessException | Thrown when the application does not have the required privilege. |
| System.InvalidOperationException | Thrown when the method failed due to the wrong pipeline description or internal error. |
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(params 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.
Exceptions
| Type | Condition |
|---|---|
| System.NotSupportedException | Thrown when the feature is not supported. |
| System.ArgumentException | Thrown when the method failed due to an invalid parameter. |
| System.UnauthorizedAccessException | Thrown when the application does not have the required privilege. |
| System.InvalidOperationException | Thrown when the method failed due to the wrong pipeline description or internal error. |
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.
Exceptions
| Type | Condition |
|---|---|
| System.NotSupportedException | Thrown when the feature is not supported. |
| System.ArgumentException | Thrown when the method failed due to an invalid parameter. |
| System.UnauthorizedAccessException | Thrown when the application does not have the required privilege. |
| System.InvalidOperationException | Thrown when the method failed due to the wrong pipeline description or internal error. |
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(params 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.
Exceptions
| Type | Condition |
|---|---|
| System.NotSupportedException | Thrown when the feature is not supported. |
| System.ArgumentException | Thrown when the method failed due to an invalid parameter. |
| System.UnauthorizedAccessException | Thrown when the application does not have the required privilege. |
| System.InvalidOperationException | Thrown when the method failed due to the wrong pipeline description or internal error. |
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().
Exceptions
| Type | Condition |
|---|---|
| System.NotSupportedException | Thrown when the feature is not supported. |
| System.ArgumentException | Thrown when the method failed due to an invalid parameter. |
| System.UnauthorizedAccessException | Thrown when the application does not have the required privilege. |
| System.InvalidOperationException | Thrown when the method failed due to the wrong pipeline description or internal error. |
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.
Exceptions
| Type | Condition |
|---|---|
| System.NotSupportedException | Thrown when the feature is not supported. |
| System.ArgumentException | Thrown when the method failed due to an invalid parameter. |
| System.UnauthorizedAccessException | Thrown when the application does not have the required privilege. |
| System.InvalidOperationException | Thrown when the method failed due to the wrong pipeline description or internal error. |