From 0d65cfaab050295c311d9f2fb28388435359db27 Mon Sep 17 00:00:00 2001 From: Allen Wang Date: Mon, 12 Oct 2020 10:39:23 -0700 Subject: [PATCH] Add an additional `NoneType` check when converting a traced tensor to a `KerasTensor`. PiperOrigin-RevId: 336694750 Change-Id: Ic79bc3b46b81d4816a7108ed9b1aa426e7f4d3d5 --- tensorflow/python/keras/engine/keras_tensor.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tensorflow/python/keras/engine/keras_tensor.py b/tensorflow/python/keras/engine/keras_tensor.py index 0c2c8bfc44d..055752026c7 100644 --- a/tensorflow/python/keras/engine/keras_tensor.py +++ b/tensorflow/python/keras/engine/keras_tensor.py @@ -170,7 +170,8 @@ class KerasTensor(object): name = getattr(tensor, 'name', None) type_spec = type_spec_module.type_spec_from_value(tensor) inferred_value = None - if (type_spec.dtype == dtypes.int32 and type_spec.shape.rank < 2): + if (type_spec.dtype == dtypes.int32 and type_spec.shape.rank is not None + and type_spec.shape.rank < 2): # If this tensor might be representing shape information, # (dtype=int32, rank of 0 or 1, not too large to represent a shape) # we attempt to capture any value information tensorflow's