W3cubDocs

/TensorFlow 1.15

tf.TensorSpec

View source on GitHub

Describes a tf.Tensor.

Metadata for describing the tf.Tensor objects accepted or returned by some TensorFlow APIs.

Args
shape Value convertible to tf.TensorShape. The shape of the tensor.
dtype Value convertible to tf.DType. The type of the tensor values.
name Optional name for the Tensor.
Raises
TypeError If shape is not convertible to a tf.TensorShape, or dtype is not convertible to a tf.DType.
Attributes
dtype Returns the dtype of elements in the tensor.
name Returns the (optionally provided) name of the described tensor.
shape Returns the TensorShape that represents the shape of the tensor.
value_type

Methods

from_spec

View source

from_tensor

View source

is_compatible_with

View source

Returns True if spec_or_tensor is compatible with this TensorSpec.

Two tensors are considered compatible if they have the same dtype and their shapes are compatible (see tf.TensorShape.is_compatible_with).

Args
spec_or_tensor A tf.TensorSpec or a tf.Tensor
Returns
True if spec_or_tensor is compatible with self.

most_specific_compatible_type

View source

Returns the most specific TypeSpec compatible with self and other.

Args
other A TypeSpec.
Raises
ValueError If there is no TypeSpec that is compatible with both self and other.

__eq__

View source

Return self==value.

__ne__

View source

Return self!=value.

© 2020 The TensorFlow Authors. All rights reserved.
Licensed under the Creative Commons Attribution License 3.0.
Code samples licensed under the Apache 2.0 License.
https://www.tensorflow.org/versions/r1.15/api_docs/python/tf/TensorSpec