昇腾社区首页
中文
注册

准备自定义算法.py文件

用户自定义算法,需要在.py格式文件内写好自定义算法脚本,按以下要求准备:

  • .py文件命名需满足规则:“ alg_{algorithm_name}.py”,其中,algorithm_name为算法名。
  • .py文件内容需满足以下规则:
    def compare(my_output_dump_data, ground_true_dump_data, args):   #算法固定头格式
    #以下为算法示例
        """
        Function Description:
            compare the my output dump data and the ground true dump data by algorithm
        Parameter:
            my_output_dump_data: the my output dump data
            ground_true_dump_data: the my output dump data
            args: the algorithm arguments
        Return Value:
            the compare algorithm value, string;error_msg,string
        """

    参数说明:

    my_output_dump_data: my output dump数据,一维数组。

    ground_true_dump_data: ground true dump数据,一维数组。

    args:算法参数,用户自行解析。

    返回值:

    算法比对的结果,String格式。

    错误信息,String格式。

  • .py文件存放目录需满足:

    .py文件必须存放在“algorithm”目录下,如果该目录不存在,需要新建。