ASTORE Procedure
SAVEAS Statement
SAVEAS ANCHORBOXES=(anchors) DATA=libref.data-table INPUT=(input-options) <…> <INPUT=(input-options)> INTOFORMATTEDLEN=into-formatted-len LABELS=(output-labels) MAXOBJECTS=max-objects MODELTYPE=model-type NUMANCHORS=num-anchors ONNX=local-file-name OUTPUT=(output-options) <…> <OUTPUT=(output-options)> ORIGIMGDIMVARS=(variables) RSTORE=libref.data-table STRIDES=(strides) STORE=local-file-name XYSCALE=(xyscale) ;
The SAVEAS statement enables you to save an Open Neural Network Exchange (ONNX) model to an analytic store.
You must specify the following values:
- DATA=libref.data-table
-
names the input data table for PROC ASTORE to use. libref.data-table is a two-level name, where
- libref
refers to a collection of information that is defined in the LIBNAME statement and includes the
library, which includes a path to the data, and a session identifier, which defaults to the active session but which can be explicitly defined in the LIBNAME statement. For more information about libref, see the section Using CAS Sessions and CAS Engine Librefs.- data-table
specifies the name of the input data table.
- INPUT=(input-options)
|
- INPUTS=(input-options)
-
specifies the mapping information for the input value information of the ONNX model that you specify in ONNX= option. You can specify the following input-options:
- DECODED
specifies that the input image be decoded in pixels. By default, the input image is encoded.
- INPUTCOLORORDER=RGB | BGR
specifies the order of the image colors of the input variable that you specify in the VARS= option. When INPUTCOLORORDER=RGB, the input variable has image colors in the following order: red, green, and blue. When INPUTCOLORORDER=BGR, the input variable has image colors in the following order: blue, green, and red. By default, INPUTCOLORORDER=RGB.
- INPUTSHAPEORDER=NCHW | NHWC
specifies the order of the image dimensions of the input variable that you specify in the VARS= option. When INPUTSHAPEORDER=NCHW, the input variable has image dimensions in the following order: number of observations, color channels, height, and width. When INPUTSHAPEORDER=NHWC, the input variable has image dimensions in the following order: number of observations, height, width, and color channels. By default, INPUTSHAPEORDER=NCHW.
- MODELCOLORORDER=RGB | BGR
specifies the order of the image colors of the input tensor for the ONNX model. When MODELCOLORORDER=RGB, the input tensor has image colors in the following order: red, green, and blue. When MODELCOLORORDER=BGR, the input tensor has image colors in the following order: blue, green, and red. By default, MODELCOLORORDER=RGB.
- MODELSHAPEORDER=NCHW | NHWC
specifies the order of the image dimensions of the input tensor. When MODELSHAPEORDER=NCHW, the input tensor has image dimensions in the following order: number of observations, color channels, height, and width. When MODELSHAPEORDER=NHWC, the input tensor has image dimensions in the following order: number of observations, height, width, and color channels. By default, MODELSHAPEORDER=NCHW.
- NORMFACTOR=number
specifies the factor that is used to normalize the input. If you specify this number together with the PREPROCESS=NORMALIZE option, each input is divided by number.
- NORMMEAN=(number-list)
specifies the mean for each color that is used to normalize the input. You must specify number-list in the following order: red, green, blue.
- NORMSTD=(number-list)
-
specifies the standard deviation for each color that is used to normalize the input. You must specify number-list in the following order: red, green, blue.
If you specify number-list together with the PREPROCESS=NORMALIZE and NORMMEAN=number-list options, each color pixel is standardized by the mean and standard deviation that you specify in number-list.
- PREPROCESS=NORMALIZE
specifies the method that is used to preprocess the input and normalize the input.
- SHAPE=(number-list)
specifies the size of each dimension of the input tensor. Use this option only when the input tensor has a missing dimension size. If a model accepts a variable-sized input tensor such as Faster R-CNN, then number-list is the maximum size of each dimension of the input tensor.
-
VALUE=(number-list)
VALUES=(number-list) -
specifies the initialization values for the input tensor. The number of values in number-list must match the size of the input tensor.
Note: If you specify both the VARS= and VALUES=number-list options, the VARS= option takes precedence.
-
VARS=variable | (variables)
VAR=variable | (variables) specifies one or more variables that are mapped to an input tensor of the ONNX model.
- VARBINARYTYPE= DOUBLE | FLOAT | INT8 | INT16 | INT32 | INT64 | UINT8 | UINT16 | UINT32 | UINT64
-
specifies the data type of the variable that you specify in the VARS=variables option. You can specify the following data types:
- DOUBLE
specifies that the data type is a 64-bit double-precision floating-point number.
- FLOAT
specifies that the data type is a 32-bit floating-point number.
- INT8
specifies that the data type is a signed 8-bit integer.
- INT16
specifies that the data type is a signed 16-bit integer.
- INT32
specifies that the data type is a signed 32-bit integer.
- INT64
specifies that the data type is a signed 64-bit integer.
- UINT8
specifies that the data type is an unsigned 8-bit integer.
- UINT16
specifies that the data type is an unsigned 16-bit integer.
- UINT32
specifies that the data type is an unsigned 32-bit integer.
- UINT64
specifies that the data type is an unsigned 64-bit integer.
This VARBINARYTYPE= option applies only when you specify one variable for the input tensor. By default, VARBINARYTYPE=UINT8.
If you specify more than one INPUT= option, the order must match that of the input value information in the DESCRIBE statement. The number of INPUT= options must match the number of input tensors of the ONNX model.
Note: If you specify the INPUT= option, it must follow the DATA= option.
- ONNX=local-file-name
specifies either the file reference or the full path of a valid ONNX file.
- OUTPUT=(output-options)
|
- OUTPUTS=(output-options)
-
specifies the mapping information for the output value information of the ONNX model that you specify in the ONNX= option. You can specify the following output-options:
-
LABEL=(string-list)
LABELS=(string-list) specifies the labels for the output tensor. The number of labels must match the total dimension size that you specify in the LABELDIM=(number-list) option.
-
LABELDIM=(number-list)
LABELDIMS=(number-list) specifies the dimension indices for the LABEL=(string-list) option. Use the LABELDIM=(number-list) option when you specify the LABEL=(string-list) option.
- NAME=var-name
specifies the name of the output variable that is mapped to an output tensor of the ONNX model.
- POSTPROCESS=SOFTMAX
applies the SOFTMAX method to the output.
- SHAPE=(number-list)
specifies the size of each dimension of the output tensor. Use this number-list only when the output tensor has a missing dimension size.
If you specify more than one OUTPUT= option, the order must match that of the output value information in the DESCRIBE statement. The number of OUTPUT= options must match the number of output tensors of the ONNX model.
Note: If you specify the MODELTYPE= option, the OUTPUT= option is ignored.
-
LABEL=(string-list)
- RSTORE=libref.data-table
-
specifies the data table to contain the analytic store that saves the ONNX model that you specify in the ONNX= option.
libref.data-table is a two-level name, where libref refers to the library, and data-table specifies the name of the input data table. For more information about this two-level name, see the DATA= option and the section Using CAS Sessions and CAS Engine Librefs.
- STORE=local-file-name
-
specifies the local file to contain the analytic store that saves the ONNX model that you specify in the ONNX= option.
Note: You must specify either one RSTORE= option or one STORE= option.
You can also specify the following options:
- ANCHORBOXES=(anchors)
specifies the shape of the anchor boxes for the model that you specify in the ONNX= option. The shape of an anchor box consists of the width and height of the box. The order of values in the number-list is as follows: the width of the first anchor box, the height of the first anchor box, the width of the second anchor box, the height of the second anchor box, and so on. The number of values in the number-list must be 2 times the number that you specify in the NUMANCHORS= option.
- INTOFORMATTEDLEN=into-formatted-len
specifies the length of the INTO column for scoring. You must specify this option if you want the INTO column to appear in the scoring output for classification models.
-
LABELS=(output-labels)
LABEL=(output-labels) specifies the labels for the output classes. The number of labels must match that of the ONNX model.
- MAXOBJECTS=max-objects
specifies the maximum number of objects to be detected. Use this option when you specify the MODELTYPE= option. By default, MAXOBJECTS=10.
- MODELTYPE=FASTERRCNN | SSD | YOLOV2 | YOLOV3 | YOLOV4
-
specifies the model type for the ONNX file that you specify in the ONNX= option. You can specify the following model types:
- FASTERRCNN
specifies a Faster R-CNN model.
- SSD
specifies a single-stage detector model.
- YOLOV2
specifies a YOLO version 2 model.
- YOLOV3
specifies a YOLO version 3 model.
- YOLOV4
specifies a YOLO version 4 model.
If you specify the MODELTYPE= option, the model-specific postprocessing is applied during scoring.
- NUMANCHORS=num-anchors
specifies the number of anchor boxes for the model that you specify in the ONNX= option. Use this option when you specify the MODELTYPE=YOLOV2 or YOLOV4 option.
- ORIGIMGDIMVARS=(variables)
specifies variables that correspond to the dimensions of the original image. You must specify the height as the first variable, then specify the width.
-
STRIDES=stride | (strides)
STRIDE=stride | (strides) specifies the stride(s) of the output tensor(s) for the model that you specify in the ONNX= option. Use this option when you specify the MODELTYPE=YOLOV4 option.
- XYSCALE=(xyscale)
specifies the scale for the X and Y coordinates of the bounding boxes for the model that you specify in the ONNX= option. Use this option when you specify the MODELTYPE=YOLOV4 option.