From 71a7618919ea5f35f2a4de40ab2b1a62d12e1d43 Mon Sep 17 00:00:00 2001 From: Tianqi Chen Date: Sun, 24 Sep 2017 10:06:37 -0700 Subject: [PATCH] [ATTR] More robust attr parsing (#33) --- nnvm/include/nnvm/tuple.h | 2 -- nnvm/python/nnvm/top/attr_dict.py | 12 +++++++++++- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/nnvm/include/nnvm/tuple.h b/nnvm/include/nnvm/tuple.h index b3193ca29eb8..551300b277ca 100644 --- a/nnvm/include/nnvm/tuple.h +++ b/nnvm/include/nnvm/tuple.h @@ -202,8 +202,6 @@ class Tuple { if (it != begin) os << ','; os << *it; } - // python style tuple - if (t.ndim() == 1) os << ','; os << ']'; return os; } diff --git a/nnvm/python/nnvm/top/attr_dict.py b/nnvm/python/nnvm/top/attr_dict.py index b5baf3decbde..2c37a0e40d6a 100644 --- a/nnvm/python/nnvm/top/attr_dict.py +++ b/nnvm/python/nnvm/top/attr_dict.py @@ -94,7 +94,17 @@ def get_bool(self, key): value : bool The result value """ - return self[key] != "False" + lowercase = self[key].lower() + if lowercase == "1": + return True + elif lowercase == "0": + return False + elif lowercase == "true": + return True + elif lowercase == "false": + return False + else: + raise ValueError("Wrong bool format for key %s" % key) def __repr__(self): return str({k : self[k] for k in self.keys()})