Add an additional NoneType check when converting a traced tensor to a KerasTensor.

PiperOrigin-RevId: 336694750
Change-Id: Ic79bc3b46b81d4816a7108ed9b1aa426e7f4d3d5
This commit is contained in:
Allen Wang 2020-10-12 10:39:23 -07:00 committed by TensorFlower Gardener
parent d855fc792a
commit 0d65cfaab0

View File

@ -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