tf.TensorSpec

Class TensorSpec

Aliases:

  • Class tf.TensorSpec
  • Class tf.contrib.eager.TensorSpec
  • Class tf.contrib.framework.TensorSpec

Defined in tensorflow/python/framework/tensor_spec.py.

Describes a tf.Tensor.

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

__init__

__init__(
    shape,
    dtype,
    name=None
)

Creates a TensorSpec.

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:

Properties

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.

Methods

tf.TensorSpec.__eq__

__eq__(other)

Return self==value.

tf.TensorSpec.__ne__

__ne__(other)

Return self!=value.

tf.TensorSpec.from_spec

@classmethod
from_spec(
    cls,
    spec,
    name=None
)

tf.TensorSpec.from_tensor

@classmethod
from_tensor(
    cls,
    tensor,
    name=None
)

tf.TensorSpec.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).

Args:

  • spec_or_tensor: A tf.TensorSpec or a tf.Tensor

Returns:

True if spec_or_tensor is compatible with self.