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


Python Tracker.simulate方法代码示例

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


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

示例1: visualize

# 需要导入模块: from tracker import Tracker [as 别名]
# 或者: from tracker.Tracker import simulate [as 别名]
    def visualize(self, out_filename="out/training_bs.html", out_filename_pickle="out/training_bs.pickle"):
        # Do bootstrap for the confusion table.
        n_bs = 1
        widgets = [progressbar.Percentage(),
                   ' ', progressbar.Bar(),
                   ' ', progressbar.ETA(),
                   ' ', progressbar.AdaptiveETA()]
        bs_progress = progressbar.ProgressBar(widgets=widgets).start()

        cts = []
        for bs_iter in bs_progress(range(n_bs)):
            n_dialogs = len(self.training_dialogs)

            dataset = self.training_dialogs

            tracker = Tracker(self.model, inv=False)
            tracker.simulate(dataset)
            cts.append(tracker.out_data['confusion_tables'])

        ct = bootstrap.from_all_confusion_tables(cts)

        context = {}
        context['tracker'] = tracker.out_data
        context['bootstrap_ct'] = ct
        context['mean_score'] = np.mean([ctt.mean_score for ctt in ct.values()])
        context['model'] = self.model
        context['training_metrics'] = self.training_metrics
        context['training_data'] = self.training_dialogs
        env = Environment(loader=FileSystemLoader('tpl'))
        env.globals.update(zip=zip)

        tpl = env.get_template('training.html')
        with open(out_filename, "w") as f_out:
            f_out.write(tpl.render(**context))
        with open(out_filename_pickle, "w") as f_out:
            info = {
                'mean_score': float(context['mean_score']),
                'losses': [float(x) for x in context['training_metrics']['losses']],
                #'simulation': context['tracker']['simulation']
            }
            f_out.write(json.dumps(info))
开发者ID:ticcky,项目名称:vspace,代码行数:43,代码来源:vspace2.py


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