Help protect the Great Barrier Reef with TensorFlow on Kaggle Join Challenge


Describes a tf.Tensor.

Inherits From: TypeSpec

Used in the notebooks

Used in the guide Used in the tutorials

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.

TypeError If shape is not convertible to a tf.TensorShape, or dtype is not convertible to a tf.DType.

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 The Python type for values that are compatible with this TypeSpec.



View source

Returns a TensorSpec with the same shape and dtype as spec.

spec = tf.TensorSpec(shape=[8, 3], dtype=tf.int32, name="OriginalName")
tf.TensorSpec.from_spec(spec, "NewName")
TensorSpec(shape=(8, 3), dtype=tf.int32, name='NewName')

spec The TypeSpec used to create the new TensorSpec.
name The name for the new TensorSpec. Defaults to


View source

Returns a TensorSpec that describes tensor.

tf.TensorSpec.from_tensor(tf.constant([1, 2, 3]))
TensorSpec(shape=(3,), dtype=tf.int32, name=None)

tensor The tf.Tensor that should be described.
name A name for the TensorSpec. Defaults to

A TensorSpec that describes tensor.


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

spec_or_tensor A tf.TensorSpec or a tf.Tensor

True if spec_or_tensor is compatible with self.


View source

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.