From cd2e817ea0aef03988656008fd5341da0c491e75 Mon Sep 17 00:00:00 2001 From: tianyilt <41582525+tianyilt@users.noreply.github.com> Date: Mon, 9 Nov 2020 20:45:09 +0800 Subject: [PATCH] fix format_err_str function in mytorch.py Fix error type: list has no attribute ravel. The error raises if we run the following: python exp.py --net rnn_vgg16unet3_gruunet4.64.3 --cmd eval --iter last --eval-dsets tat-subseq --eval-scale 0.5 Only np array has attribute ravel. But isinstance(v, (np.ndarray, list)) make list operate list.ravel which will cause error. --- co/mytorch.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/co/mytorch.py b/co/mytorch.py index 19986e0..e3dee8a 100644 --- a/co/mytorch.py +++ b/co/mytorch.py @@ -542,7 +542,10 @@ def get_eval_data_loader(self, dset): def format_err_str(self, errs, div=1): err_list = [] for v in errs.values(): - if isinstance(v, (list, np.ndarray)): + if isinstance(v, np.ndarray): + err_list.extend(v.ravel()) + elif isinstance(v, list): + v=np.array(v) err_list.extend(v.ravel()) else: err_list.append(v)