diff --git a/tensorflow/python/framework/tensor_util.py b/tensorflow/python/framework/tensor_util.py index eea3d28a7e4..d2d95a5f9dd 100644 --- a/tensorflow/python/framework/tensor_util.py +++ b/tensorflow/python/framework/tensor_util.py @@ -236,7 +236,9 @@ def _FilterTuple(v): def _FilterInt(v): if isinstance(v, (list, tuple)): return _FirstNotNone([_FilterInt(x) for x in v]) - return None if isinstance(v, compat.integral_types) else _NotNone(v) + return None if isinstance( + v, + compat.integral_types, tensor_shape.Dimension) else _NotNone(v) def _FilterFloat(v): diff --git a/tensorflow/python/util/compat.py b/tensorflow/python/util/compat.py index cae41a7230c..07382d93dfe 100644 --- a/tensorflow/python/util/compat.py +++ b/tensorflow/python/util/compat.py @@ -40,7 +40,6 @@ import numbers as _numbers import numpy as _np import six as _six -from tensorflow.python.framework import tensor_shape from tensorflow.python.util.all_util import remove_undocumented @@ -111,7 +110,7 @@ def as_str_any(value): # Numpy 1.8 scalars don't inherit from numbers.Integral in Python 3, so we # need to check them specifically. The same goes from Real and Complex. -integral_types = (_numbers.Integral, _np.integer, tensor_shape.Dimension) +integral_types = (_numbers.Integral, _np.integer) real_types = (_numbers.Real, _np.integer, _np.floating) complex_types = (_numbers.Complex, _np.number)