当前位置: 首页>>代码示例>>Python>>正文


Python Evaluator.get_result方法代码示例

本文整理汇总了Python中evaluator.Evaluator.get_result方法的典型用法代码示例。如果您正苦于以下问题:Python Evaluator.get_result方法的具体用法?Python Evaluator.get_result怎么用?Python Evaluator.get_result使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在evaluator.Evaluator的用法示例。


在下文中一共展示了Evaluator.get_result方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: run_cnn

# 需要导入模块: from evaluator import Evaluator [as 别名]
# 或者: from evaluator.Evaluator import get_result [as 别名]
def run_cnn(model_params, optimization_params, dataset_path, dataset_params, filename_params, visual_params, epochs, verbose=False):
    print(filename_params)
    if not os.path.exists(filename_params.results):
        os.makedirs(filename_params.results)

    is_config, config_values = interface.command.get_command("-config")
    is_curriculum, curriculum_set = interface.command.get_command("-curriculum")
    is_batch_run, batch_index = interface.command.get_command("-batch", default="0")
    is_init_params, param_path = interface.command.get_command("-params")

    if is_config:
        #Assume  config is speficially for running bootstrapping batches.
        config_arr = eval(config_values)
        if len(config_arr) == 2:
            loss_function = config_arr[0]
            label_noise = float(config_arr[1])
            dataset_params.label_noise = label_noise
            model_params.loss = loss_function
            batch_index = loss_function + "-" + str(label_noise) + "-" + batch_index
            print(batch_index)

    if is_curriculum:
        dataset_path = curriculum_set

    weights = None
    if is_init_params:
        store = ParamStorage()
        if not param_path:
            param_path = "./results/params.pkl"
        weights = store.load_params(path=param_path)['params']


    dataset = DataLoader.create()
    dataset.load(dataset_path, dataset_params, optimization_params.batch_size) #Input stage
    model = ConvModel(model_params, verbose=True) #Create network stage

    evaluator = Evaluator(model, dataset, optimization_params, dataset_path)
    evaluator.run(epochs=epochs,  verbose=verbose, init=weights)
    report = evaluator.get_result()
    network_store_path = filename_params.network_save_name
    result_path = filename_params.results + "/results.json"
    if is_batch_run:
        network_store_path = filename_params.results + "/batch" + batch_index +  ".pkl"
        result_path =filename_params.results + "/batch" + batch_index +  ".json"

    storage = ParamStorage(path=network_store_path)
    storage.store_params(model.params)

    dataset.destroy()

    if visual_params.gui_enabled:
         interface.server.stop_job(report)

    printing.print_section('Evaluation precision and recall')

    prc = PrecisionRecallCurve(pr_path, model.params, model_params, dataset_params)
    test_datapoints = prc.get_curves_datapoints(optimization_params.batch_size, set_name="test")
    valid_datapoints = prc.get_curves_datapoints(optimization_params.batch_size, set_name="valid")
    #Stores the model params. Model can later be restored.
    printing.print_section('Storing model parameters')

    if visual_params.gui_enabled:
        interface.server.send_precision_recall_data(test_datapoints, valid_datapoints)
    storage.store_result(result_path, evaluator.events, test_datapoints, valid_datapoints)
开发者ID:olavvatne,项目名称:CNN,代码行数:66,代码来源:cnn.py


注:本文中的evaluator.Evaluator.get_result方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。