Creating an Algorithm
If you have developed an algorithm locally, upload the algorithm to ModelArts for management. You can use cloud resources to train the uploaded algorithm to obtain a desired model. And then you can share the generated model to others through AI Gallery or deploy it as a service on ModelArts. For details about the algorithm format requirements, see What Are the Format Requirements for Algorithms Imported from a Local Environment?
Creating an Algorithm
- Log in to the ModelArts management console and click Algorithm Management in the left navigation pane.
- On the My Algorithms page, click Create. The Create Algorithm page is displayed.
- On the Create Algorithm page, set related parameters.
- Set the basic parameters, including Billing Mode, Name, Version, and Description. For Billing Mode, only Pay-per-use is supported. Currently no fee will generate because the algorithm management function is in the open beta test.
Figure 1 Setting basic parameters
- Set parameter Created by. Currently, only custom scripts can be used to create algorithms. You need to set AI Engine, Code Directory, and Boot File based on the actual algorithm code. The framework of the AI engine you select must be the same as the one used when compiling algorithm code. For example, if TensorFlow is used for your algorithm code, select TensorFlow when you create an algorithm.
Table 1 Parameter description Parameter
Description
AI Engine
AI engine. For details about how to create an AI engine supported by an algorithm, see Table 1.
Code Directory
OBS path for storing algorithm code. Upload the code file to OBS in advance. The code directory cannot contain files or directories uploaded by others or irrelevant files or directories. Otherwise, the upload may fail.
Boot File
Must be in the code directory and end with .py or .pyc. That is, ModelArts supports only boot files compiled in Python.
Figure 2 Creating an algorithm using custom scripts
- Set Input Path Mapping Configuration and Output Path Mapping Configuration. The two parameters are optional. You can determine whether to set them based on the site requirements. For details about the parameters, see Table 2.
The parameters configuration methods are as follows:
Input Path Mapping Configuration: Parameter data_url is displayed by default. You can enter the local path of the container in Mapping Path. You can enter only one directory name. Multi-level directories are not supported. That is, the slash (/) is not supported. Only letters, digits, hyphens (-), and underscores (_) are allowed. You can click Add Input Path Mapping to add a parameter, or click the deletion icon on the right to delete a parameter.
Output Path Mapping Configuration: Parameter train_url is displayed by default. You can enter the local path of the container in Mapping Path. You can enter only one directory name. Multi-level directories are not supported. That is, the slash (/) is not supported. Only letters, digits, hyphens (-), and underscores (_) are allowed. You can click Add Output Path Mapping to add a parameter, or click the deletion icon on the right to delete a parameter.
Table 2 Parameter description Parameter
Detailed Description
Brief Description
Input Path Mapping Configuration
Create an input path mapping for your algorithm. The mapping path is the local path of the computing container. When you use the algorithm to create a training task, a corresponding cloud storage location will be created for each input path mapping configuration. When the training starts, the system transmits the data in the cloud storage location to the corresponding mapping path (local path of the container). The local path of the container is sent to your algorithm script or image in the form of "key=value" command line parameter from the startup command. You only need to parse the input parameter and access the data in the local path of the container.
Simply speaking, the input mapping path is the local path of the container. It is used to copy OBS data to this local path for local code use when the training starts.
Output Path Mapping Configuration
Create an output path mapping for your algorithm. The mapping path is the local path of the computing container. When you use the algorithm to create a training task, a corresponding cloud storage location will be created for each output path mapping configuration. When the training completes, the system transmits the data in the mapping path (local path of the container) to the cloud storage location you select. The local path of the container is sent to your algorithm script or image in the form of "key=value" command line parameter from the startup command. You only need to parse the input parameter and save the output data in the local path of the container.
Simply speaking, the output mapping path is the local path of the container. It is used to copy the data generated during training to OBS after the training completes.
Figure 3 Setting Input Path Mapping Configuration and Output Path Mapping Configuration
- Check Start command.
The start command is automatically generated and does not need to be entered.Figure 4 Setting the start command
- Click Next in the lower right corner to switch to the Hyperparameter Specifications page.
- On the Hyperparameter Specifications page, you can define hyperparameters of the algorithm based on your needs. The hyperparameter configurations are optional. You can skip it and proceed with the next step.
- Import Parameters: If you use a custom Python script to create an algorithm and use argparse or tf.app.flags in the boot file to define input parameter parsing, enable Import Parameters and set Parameter Source to the hyperparameter file path to pre-fill hyperparameters.
- Show Example: Click Show Example to view the example of hyperparameter configurations, from which you can learn how to set a hyperparameter. When the parameter type is string, the default value cannot be null.
- Add Hyperparameter: Click Add Hyperparameter below the list to add more hyperparameters. Set the hyperparameters based on Show Example.
- User-Defined Hyperparameter: Select Enabled or Disabled to determine whether to support custom hyperparameters.
You can delete, modify, or clear a hyperparameter by clicking corresponding buttons.
Figure 5 Defining hyperparameters
- Click Next in the lower right corner to switch to the Constraints page.
- On the Constraints page, you can define the input constraints and training constraints of the algorithm based on the site requirements.
- Input constraints
- Data Source: Set the value to a data storage location, ModelArts dataset, or both.
- Labeling Type: Select the required labeling type from the drop-down list based on the algorithm if your data sources include ModelArts datasets.
- Data Format: Select a data format if your data sources include ModelArts datasets. You can set the value to Default, CarbonData, or both. Default indicates the manifest format.
- Data Segmentation: Select a data segmentation mode if your data sources include ModelArts datasets. Possible values are Segmented dataset, Dataset not segmented, and Unlimited.
Figure 6 Algorithm input constraints
- Training constraints
- Resource Type: The options are CPU, GPU, and Ascend. You can select multiple options.
- Multicard Training: Select Supported or Not supported.
- Distributed Training: Select Supported or Not supported.
- Recommended Flavor: Select the resource flavor recommended for the algorithm. That is, when you need to use your algorithm to train a model, you are advised to select the recommended resource flavor. In the drop-down list, you can select desired resource flavors supported by ModelArts for training.
Figure 7 Algorithm training constraints
- Input constraints
- Click Submit. You can return to the Algorithm Management page as prompted.
- Set the basic parameters, including Billing Mode, Name, Version, and Description. For Billing Mode, only Pay-per-use is supported. Currently no fee will generate because the algorithm management function is in the open beta test.
- On the Algorithm Management page, wait until the algorithm is ready. When the status of the created algorithm changes to Ready, you can perform other operations.
Figure 8 Algorithm ready
Follow-Up Procedure
You can use the created algorithm to quickly create a training job and build a model. For details, see Creating a Training Job Using an Algorithm.
Last Article: Overview
Next Article: Creating a Training Job Using an Algorithm
Did this article solve your problem?
Thank you for your score!Your feedback would help us improve the website.