當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。