From e19c92334cebaa79298743d7e489985064d2ed41 Mon Sep 17 00:00:00 2001 From: Reed Wanderman-Milne Date: Mon, 6 Jan 2020 11:00:27 -0800 Subject: [PATCH] Remove useless hasattr check in Layer.get_config. The hasattr(self, 'dtype') check would only fail if super().__init__ is not called. If not called, Layer.get_config and most other methods already raise errors anyway. PiperOrigin-RevId: 288333917 Change-Id: I1962be09c9c4686c76120298411f3156b561f734 --- tensorflow/python/keras/engine/base_layer.py | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/tensorflow/python/keras/engine/base_layer.py b/tensorflow/python/keras/engine/base_layer.py index 0b9c658d24f..2f45af369df 100644 --- a/tensorflow/python/keras/engine/base_layer.py +++ b/tensorflow/python/keras/engine/base_layer.py @@ -487,10 +487,7 @@ class Layer(module.Module): config = {'name': self.name, 'trainable': self.trainable} if hasattr(self, '_batch_input_shape'): config['batch_input_shape'] = self._batch_input_shape - # TODO(reedwm): Remove the hasattr(self, 'dtype') check. All layers have a - # dtype. - if hasattr(self, 'dtype'): - config['dtype'] = policy.serialize(self._dtype_policy) + config['dtype'] = policy.serialize(self._dtype_policy) if hasattr(self, 'dynamic'): # Only include `dynamic` in the `config` if it is `True` if self.dynamic: