tf.contrib.eager.TensorSpec

Class TensorSpec

Aliases:

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

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

Describes a tf.Tensor.

A TensorSpec allows an API to describe the Tensors that it accepts or returns, before that Tensor exists. This allows dynamic and flexible graph construction and configuration.

__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.

is_continuous

Whether spec is continuous.

is_discrete

Whether spec is discrete.

name

Returns the name of the described tensor.

shape

Returns the TensorShape that represents the shape of the tensor.

Methods

__eq__

__eq__(other)

__ne__

__ne__(other)

from_spec

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

from_tensor

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

is_bounded

@classmethod
is_bounded(cls)

is_compatible_with

is_compatible_with(spec_or_tensor)

True if the shape and dtype of spec_or_tensor are compatible.