Expand composites in tf.test.TestCase.evaluate.
This is helpful to allow CompositeTensors to be used with tf.test.TestCase.evaluate. PiperOrigin-RevId: 313446907 Change-Id: I74ab70647b674689f36ea5738b57d44d02ec9685
This commit is contained in:
parent
426869b50f
commit
49a5378fb1
@ -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)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user