diff --git a/tensorflow/python/framework/test_util.py b/tensorflow/python/framework/test_util.py index 4981e1b68fd..4451d90a490 100644 --- a/tensorflow/python/framework/test_util.py +++ b/tensorflow/python/framework/test_util.py @@ -2128,7 +2128,9 @@ class TensorFlowTestCase(googletest.TestCase): values=tensor.values.numpy(), indices=tensor.indices.numpy(), dense_shape=tensor.dense_shape.numpy()) - return tensor.numpy() + # Convert tensors and composite tensors to numpy arrays. + return nest.map_structure(lambda t: t.numpy(), tensor, + expand_composites=True) except AttributeError as e: six.raise_from(ValueError("Unsupported type %s." % type(tensor)), e)