PretrainIndex

Function Usage

Pre-train the index used by the AscendKMeans to save the time for repeatedly creating indexes.

Prototype

APP_ERROR PretrainIndex(std::vector<float> &features, faiss::Index *&pretrainedIndex, bool addData);

Parameter Description

Parameter

Description

features

Input vector for feature clustering. Its length is equal to the value of FeatureCount * Dim.

pretrainedIndex

Input retrieval index to be pretrained. It needs to be set to nullptr. After the execution is complete, a non-null pointer is returned.

After using the pointer, explicitly delete the pointer and set it to null.

addData

Whether to add the input featureData to the index. If this parameter is set to false, the returned number of features in pretrainedIndex is empty. If this parameter is set to true, the data in features is added to pretrainedIndex after the pre-training is complete.

Response Parameters

Data Structure

Description

APP_ERROR

0: pre-training completed.