All Products
Search
Document Center

:model prune

更新時間:Sep 14, 2024

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 the permissions that are required to use Machine Learning Designer.

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 type

    Recommended upstream component

    Required

    Input models

    OSS

    object detection

    No

    Training data

    OSS

    Read File Data

    Yes

    Evaluation data

    OSS

    Read File Data

    Yes

    yolov5 class list files

    OSS

    Read File Data

    Yes

  • Component parameters

    Tab

    Parameter

    Description

    Fields Setting

    model type

    The type of the model to train. Valid values:

    • YOLOX

    • YOLOX_EDGE

    Default value: YOLOX_EDGE.

    oss path to save checkpoint

    The Object Storage Service (OSS) path of the model and logs generated during training.

    oss path to training tfrecord

    The 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 set

    The OSS path of the file that contains the labeled training data.

    oss path to evaluation file

    The 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 set

    The OSS path of the file that contains the labeled evaluation data.

    oss path of class list file

    The 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 format

    The format of the datasets. Valid values:

    • COCO

    • DetSourcePAI

    Default value: COCO.

    oss path to pretrained model

    The OSS path of a pre-trained model. You must import the pre-trained weight file. Optional.

    Parameters Setting

    YOLOX edge model type

    This 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 type

    This 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 class

    The type of the pruning algorithm. Default value: AGP.

    pruning algorithm

    The pruning algorithm. Default value: taylorfo.

    yolox_edge_model_depth

    This 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_width

    This 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 activation

    This 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 classes

    The number of categories.

    image scale

    The resolution of resized images for YOLOX. The value is in the format of Height Width. Default value: 640 640.

    initial learning rate

    The initial learning rate for model training. The value is a floating-point number. Default value: 0.01.

    train batch size

    The size of the data that is used to train the model in each batch. Default value: 16.

    eval batch size

    The size of the data that is used to evaluate the model in each batch. Default value: 1.

    num epochs

    The total number of training epochs. Default value: 20.

    warmup epochs

    By default, five epochs are set for the warm-up strategy.

    last no augmented lr epochs

    The number of epochs to complete after the learning rate is stable if the warm-up strategy is used. Default value: 5.

    save checkpoint epoch

    The 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.

    Tuning

    io 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 DLC

    The 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 worker

    The number of workers used for distributed training. Default value: 1.

    gpu machine type

    The 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.