Machine Learning Platform for AI (PAI) provides the model prune component that is based on Taylor First order pruning (TaylorFO). TaylorFO is a mainstream adaptive growing and pruning algorithm (AGP). You can use a model prune component to compress models for high training and inference performance. This topic describes how to configure the model prune component and provides an example on how to use the component.

Prerequisites

OSS is activated, and Machine Learning Studio is authorized to access OSS. For more information, see Activate OSS and Grant PAI the permissions to access OSS.

Limits

  • The model quantize component is available only in Machine Learning Designer of Machine Learning Platform for AI.
  • You can use the model quantize component based only on the computing resources of Deep Learning Containers (DLC) of Machine Learning Platform for AI.
  • If an object detection component is configured as an upstream component of the model quantize component, make sure that the model-related configurations and the dataset configurations for the two components are the same.

Configure the component in Machine Learning Designer

  • Input ports
    Input port (from left to right)Data typeRecommended upstream componentRequired
    Input modelsOSSobject detectionNo
    Training dataOSSRead File DataYes
    Evaluation dataOSSRead File DataYes
    yolov5 class list filesOSSRead File DataYes
  • Component parameters
    TabParameterDescription
    Fields Settingmodel typeThe type of the model to train. Valid values:
    • YOLOX
    • YOLOX_EDGE

    Default value: YOLOX_EDGE.

    oss path to save checkpointThe Object Storage Service (OSS) path of the model and logs generated during training.
    oss path to training tfrecordThe OSS path of the file that contains the training data. If a Read File Data component is configured as an upstream node, you do not need to set this parameter.
    oss annotation path for training setThe OSS path of the file that contains the labeled training data.
    oss path to evaluation fileThe OSS path of the file that contains the evaluation data. If a Read File Data component is configured as an upstream node, you do not need to set this parameter.
    oss annotation path for validataion setThe OSS path of the file that contains the labeled evaluation data.
    oss path of class list fileThe OSS path of the category file. If a Read File Data component is configured as an upstream node, you do not need to set this parameter.
    YOLOX data formatThe format of the datasets. Valid values:
    • COCO
    • DetSourcePAI

    Default value: COCO.

    oss path to pretrained modelThe OSS path of a pre-trained model. You must import the pre-trained weight file. Optional.
    Parameters SettingYOLOX edge model typeThis parameter is required only if you set the model type parameter to YOLOX_EDGE on the Fields Setting tab.

    The type of the YOLOX preset model. Default value: yolox-customized.

    YOLOX model typeThis parameter is required only if you set the model type parameter to YOLOX on the Fields Setting tab.
    Valid values:
    • yolox-s
    • yolox-m
    • yolox-l
    • yolox-x

    Default value: yolox-s.

    pruning classThe type of the pruning algorithm. Default value: AGP.
    pruning algorithmThe pruning algorithm. Default value: taylorfo.
    yolox_edge_model_depthThis parameter is required only if you set the model type parameter to YOLOX_EDGE on the Fields Setting tab.

    The depth of the YOLOX model. The value is a floating-point number. Default value: 1.0. Valid values: 0.01 to 1.0.

    yolox_edge_model_widthThis parameter is required only if you set the model type parameter to YOLOX_EDGE on the Fields Setting tab.

    The width of the YOLOX model. The value is a floating-point number. Default value: 1.0. Valid values: 0.01 to 1.0.

    YOLOX edge model activationThis parameter is required only if you set the model type parameter to YOLOX_EDGE on the Fields Setting tab.
    The type of the activation function for the YOLOX model. Valid values:
    • relu
    • lrelu
    • silu
    • hsilu

    Default value: relu.

    test confidence:[0.01,1.0]This parameter is required only if you set the model type parameter to YOLOX_EDGE on the Fields Setting tab.

    The confidence level of the evaluation. The value is a floating-point number. Default value: 0.01. Valid values: 0.01 to 1.0.

    nms threshold:[0.01,1.0]This parameter is required only if you set the model type parameter to YOLOX_EDGE on the Fields Setting tab.

    The Non-Maximum Suppression (NMS) threshold. The value is a floating-point number. Default value: 0.65. Valid values: 0.01 to 1.0.

    num classesThe number of categories.
    image scaleThe resolution of resized images for YOLOX. The value is in the format of Height Width. Default value: 640 640.
    initial learning rateThe initial learning rate for model training. The value is a floating-point number. Default value: 0.01.
    train batch sizeThe size of the data that is used to train the model in each batch. Default value: 16.
    eval batch sizeThe size of the data that is used to evaluate the model in each batch. Default value: 1.
    num epochsThe total number of training epochs. Default value: 20.
    warmup epochsBy default, five epochs are set for the warm-up strategy.
    last no augmented lr epochsThe number of epochs to complete after the learning rate is stable if the warm-up strategy is used. Default value: 5.
    save checkpoint epochThe interval at which a checkpoint is saved. The interval is measured in epochs. Default value: 1. The default value indicates that a checkpoint is saved every time an epoch is complete.
    Tuningio thread num for training.The number of concurrent threads that are used to read the training data. Default value: 4.
    single worker or distributed on MaxCompute or DLCThe compute engine that is used to run the component. The system automatically sets this parameter based on the type of the training model that you select.
    number of workerThe number of workers used for distributed training. Default value: 1.
    gpu machine typeThe instance type of the GPU-accelerated instance to be used. Default value: 8vCPU+32GB Mem+1xv100-ecs.gn6v-c8g1.2xlarge.

Example

The following figure shows a sample pipeline in which a model prune component is used. PipelineIn this example, the components are configured by performing the following steps:
  1. Perform data labeling by using iTAG that is provided by PAI. For more information, see iTAG.
  2. Use the Read File Data-1, Read File Data-2, and Read File Data-3 components to read the training dataset, evaluation dataset, and category file. You can configure the dataset to be read for a Read File Data component by setting the OSS Data Path component parameter to the OSS path of the training dataset, evaluation dataset, or category file.
  3. Use the object detection-1 component to generate an object detection model.
  4. Use the Read File Data-4, Read File Data-5, and Read File Data-6 components to read the training dataset, evaluation dataset, and category file. You can configure the dataset to be read for a Read File Data component by setting the OSS Data Path component parameter to the OSS path of the training dataset, evaluation dataset, or category file.
  5. Connect the object detection-1, Read File Data-4, Read File Data-5, and Read File Data-6 components to the model prune component and set the component parameters. For more information, see Configure the component in Machine Learning Designer in this topic.