W3cubDocs

/TensorFlow Python

tf.contrib.framework.TensorSpec

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

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

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

__eq__

__eq__(other)

Return self==value.

__ne__

__ne__(other)

Return self!=value.

__reduce__

__reduce__()

helper for pickle

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.

© 2018 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/api_docs/python/tf/contrib/framework/TensorSpec