Skip to content

Commit 7ae6bfd

Browse files
saberkuntensorflower-gardener
authored andcommitted
PY3 migration. Autograph compatible.
PiperOrigin-RevId: 287619398
1 parent 0b87b8b commit 7ae6bfd

File tree

4 files changed

+5
-5
lines changed

4 files changed

+5
-5
lines changed

official/modeling/hyperparams/params_dict.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -111,10 +111,10 @@ def __getattr__(self, k):
111111
the value of the key.
112112
113113
Raises:
114-
KeyError: if k is not defined in the ParamsDict.
114+
AttributeError: if k is not defined in the ParamsDict.
115115
"""
116116
if k not in self.__dict__.keys():
117-
raise KeyError('The key `{}` does not exist. '.format(k))
117+
raise AttributeError('The key `{}` does not exist. '.format(k))
118118
return self.__dict__[k]
119119

120120
def __contains__(self, key):

official/modeling/hyperparams/params_dict_test.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ class ParamsDictTest(tf.test.TestCase):
2727

2828
def test_init_from_an_empty_dict(self):
2929
params = params_dict.ParamsDict()
30-
with self.assertRaises(KeyError):
30+
with self.assertRaises(AttributeError):
3131
_ = params.a
3232

3333
with self.assertRaises(KeyError):

official/vision/detection/dataloader/input_reader.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ def __init__(self,
6464
self._input_sharding = params.train.input_sharding
6565
else:
6666
self._input_sharding = params.eval.input_sharding
67-
except KeyError:
67+
except AttributeError:
6868
pass
6969

7070
def __call__(self, ctx=None, batch_size: int = None):

official/vision/detection/modeling/base_model.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ def __init__(self, params):
3939
nesterov = False
4040
try:
4141
nesterov = params.nesterov
42-
except KeyError:
42+
except AttributeError:
4343
pass
4444
self._optimizer = functools.partial(
4545
tf.keras.optimizers.SGD,

0 commit comments

Comments
 (0)