Preparing a Customized Algorithm .py File
User-defined Python files containing custom comparison algorithms can be only used for accuracy comparison. Users shall be responsible for the security of the files and input parameters.
To customize an algorithm, you need to write the customized algorithm script in a .py file and make preparations as follows:
- The .py file name must comply with alg_{algorithm_name}.py.
- The content of the .py file is as follows:
1 2 3 4 5 6 7 8 9 10 11 12
def compare(my_output_dump_data, ground_truth_dump_data, args): # Fixed header format of the algorithm # The following is an example algorithm: """ Function Description: compare the my output dump data and the ground truth dump data by algorithm Parameter: my_output_dump_data: the my output dump data ground_truth_dump_data: the ground truth dump data args: the algorithm arguments Return Value: the compare algorithm value, string; error_msg, string """
Table 1 Parameters Parameter
Description
my_output_dump_data
My output dump data, stored as a one-dimensional array.
ground_truth_dump_data
Ground truth dump data, stored as a one-dimensional array.
args
Algorithm parameter, which is parsed by users.
Return Value
Return value, including:
- Algorithm comparison result, in string format.
- Error message, in string format.
- Create the algorithm directory in the current user directory to store the .py file. Ensure that the user has the read and write permissions on the directory and file.
Parent topic: Extended Functions