View source on GitHub |
Describes a tf.Tensor.
tf.TensorSpec(
shape, dtype=tf.dtypes.float32, name=None
)
Metadata for describing the tf.Tensor
objects accepted or returned
by some TensorFlow APIs.
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.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
TypeError
: If shape is not convertible to a tf.TensorShape
, or dtype is
not convertible to a tf.DType
.__eq__
__eq__(
other
)
Return self==value.
__ne__
__ne__(
other
)
Return self!=value.
from_spec
@classmethod
from_spec(
spec, name=None
)
from_tensor
@classmethod
from_tensor(
tensor, name=None
)
is_compatible_with
is_compatible_with(
spec_or_tensor
)
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
).
spec_or_tensor
: A tf.TensorSpec or a tf.TensorTrue if spec_or_tensor is compatible with self.
most_specific_compatible_type
most_specific_compatible_type(
other
)
Returns the most specific TypeSpec compatible with self
and other
.
other
: A TypeSpec
.ValueError
: If there is no TypeSpec that is compatible with both self
and other
.