From 10ec6b5e272fbe4b4c73b3b8dc12919ef92bcaf7 Mon Sep 17 00:00:00 2001 From: Eric Gaudet Date: Wed, 6 Feb 2019 14:18:58 -0800 Subject: [PATCH] export command broken by missing metric_reporters (#271) Summary: Pull Request resolved: https://github.com/facebookresearch/pytext/pull/271 Removed an if by mistake in D13829608 Reviewed By: bethebunny Differential Revision: D13978522 fbshipit-source-id: 1adbdade1f5ca1241c15c9c3300e4a7163370be7 --- pytext/task/task.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/pytext/task/task.py b/pytext/task/task.py index d4166d591..8a4c336f5 100644 --- a/pytext/task/task.py +++ b/pytext/task/task.py @@ -177,7 +177,7 @@ def test(self, test_path): test_iter = self.data_handler.get_test_iter() return self.trainer.test(test_iter, self.model, self.metric_reporter) - def export(self, model, export_path, metric_channels, export_onnx_path=None): + def export(self, model, export_path, metric_channels=None, export_onnx_path=None): """ Wrapper method to export PyTorch model to Caffe2 model using :class:`~Exporter`. @@ -191,8 +191,9 @@ def export(self, model, export_path, metric_channels, export_onnx_path=None): cuda_utils.CUDA_ENABLED = False model = model.cpu() if self.exporter: - print("Exporting metrics") - self.exporter.export_to_metrics(model, metric_channels) + if metric_channels: + print("Exporting metrics") + self.exporter.export_to_metrics(model, metric_channels) print("Saving caffe2 model to: " + export_path) self.exporter.export_to_caffe2(model, export_path, export_onnx_path)