Commit 7ae6bfdd authored by Hongkun Yu's avatar Hongkun Yu Committed by A. Unique TensorFlower
Browse files

PY3 migration. Autograph compatible.

PiperOrigin-RevId: 287619398
parent 0b87b8b0
...@@ -111,10 +111,10 @@ class ParamsDict(object): ...@@ -111,10 +111,10 @@ class ParamsDict(object):
the value of the key. the value of the key.
Raises: Raises:
KeyError: if k is not defined in the ParamsDict. AttributeError: if k is not defined in the ParamsDict.
""" """
if k not in self.__dict__.keys(): if k not in self.__dict__.keys():
raise KeyError('The key `{}` does not exist. '.format(k)) raise AttributeError('The key `{}` does not exist. '.format(k))
return self.__dict__[k] return self.__dict__[k]
def __contains__(self, key): def __contains__(self, key):
......
...@@ -27,7 +27,7 @@ class ParamsDictTest(tf.test.TestCase): ...@@ -27,7 +27,7 @@ class ParamsDictTest(tf.test.TestCase):
def test_init_from_an_empty_dict(self): def test_init_from_an_empty_dict(self):
params = params_dict.ParamsDict() params = params_dict.ParamsDict()
with self.assertRaises(KeyError): with self.assertRaises(AttributeError):
_ = params.a _ = params.a
with self.assertRaises(KeyError): with self.assertRaises(KeyError):
......
...@@ -64,7 +64,7 @@ class InputFn(object): ...@@ -64,7 +64,7 @@ class InputFn(object):
self._input_sharding = params.train.input_sharding self._input_sharding = params.train.input_sharding
else: else:
self._input_sharding = params.eval.input_sharding self._input_sharding = params.eval.input_sharding
except KeyError: except AttributeError:
pass pass
def __call__(self, ctx=None, batch_size: int = None): def __call__(self, ctx=None, batch_size: int = None):
......
...@@ -39,7 +39,7 @@ class OptimizerFactory(object): ...@@ -39,7 +39,7 @@ class OptimizerFactory(object):
nesterov = False nesterov = False
try: try:
nesterov = params.nesterov nesterov = params.nesterov
except KeyError: except AttributeError:
pass pass
self._optimizer = functools.partial( self._optimizer = functools.partial(
tf.keras.optimizers.SGD, tf.keras.optimizers.SGD,
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment