<br />

|---|
| [![](https://www.tensorflow.org/images/GitHub-Mark-32px.png) View source on GitHub](https://github.com/tensorflow/datasets/blob/v4.9.10/tensorflow_datasets/core/features/feature.py#L83-L238) |

Structure containing info on the [`tf.Tensor`](https://www.tensorflow.org/api_docs/python/tf/Tensor) shape/dtype.

    tfds.features.TensorInfo(
        shape: Shape,
        dtype: type_utils.TfdsDType,
        default_value=None,
        sequence_rank: Optional[int] = None,
        dataset_lvl: int = 0,
        minimum: Optional[type_utils.NpArrayOrScalar] = None,
        maximum: Optional[type_utils.NpArrayOrScalar] = None,
        optional: bool = False
    )

<br />

<br />

<br />

| ## Args ||
|---|---|
| `shape` | `tuple[int]`, shape of the tensor. |
| `dtype` | Tensor DType that will be converted to NumPy DType. |
| `default_value` | Used for retrocompatibility with previous files if a new field is added to provide a default value when reading the file. |
| `sequence_rank` | `int`, Number of [`tfds.features.Sequence`](https://www.tensorflow.org/datasets/api_docs/python/tfds/features/Sequence) dimension. |
| `dataset_lvl` | `int`, if \>0, nesting level of a [`tfds.features.Dataset`](https://www.tensorflow.org/datasets/api_docs/python/tfds/features/Dataset). |
| `minimum` | Tensor minimum. This can be useful to specify [`tf_agents.specs.BoundedArraySpec`](https://www.tensorflow.org/agents/api_docs/python/tf_agents/specs/BoundedArraySpec) for example. |
| `maximum` | Tensor maximum. This can be useful to specify [`tf_agents.specs.BoundedArraySpec`](https://www.tensorflow.org/agents/api_docs/python/tf_agents/specs/BoundedArraySpec) for example. |
| `optional` | Whether the feature is optional and accepts None values. |

<br />

<br />

<br />

<br />

| ## Attributes ||
|---|---|
| `dataset_lvl` | <br /> <br /> |
| `default_value` | <br /> <br /> |
| `dtype` | Return the TensorFlow DType of this TensorInfo. |
| `maximum` | <br /> <br /> |
| `minimum` | <br /> <br /> |
| `np_dtype` | <br /> <br /> |
| `numpy_dtype` | <br /> <br /> |
| `optional` | <br /> <br /> |
| `sequence_rank` | <br /> <br /> |
| `shape` | <br /> <br /> |
| `tf_dtype` | <br /> <br /> |

<br />

## Methods

### `copy_from`

[View source](https://github.com/tensorflow/datasets/blob/v4.9.10/tensorflow_datasets/core/features/feature.py#L139-L151)

    @classmethod
    copy_from(
        tensor_info: TensorInfo
    ) -> TensorInfo

Copy constructor.

### `from_bounded_tensor_spec`

[View source](https://github.com/tensorflow/datasets/blob/v4.9.10/tensorflow_datasets/core/features/feature.py#L160-L170)

    @classmethod
    from_bounded_tensor_spec(
        tensor_spec: tf_agents.specs.BoundedTensorSpec
    ) -> TensorInfo

Creates a new TensorInfo instance from a BoundedTensorSpec.

### `from_tensor_spec`

[View source](https://github.com/tensorflow/datasets/blob/v4.9.10/tensorflow_datasets/core/features/feature.py#L153-L158)

    @classmethod
    from_tensor_spec(
        tensor_spec: tf.TensorSpec
    ) -> TensorInfo

### `to_bounded_tensor_spec`

[View source](https://github.com/tensorflow/datasets/blob/v4.9.10/tensorflow_datasets/core/features/feature.py#L187-L199)

    to_bounded_tensor_spec() -> tf_agents.specs.BoundedTensorSpec

Converts this TensorInfo instance to a tf.BoundedTensorSpec.

<br />

<br />

<br />

| Returns ||
|---|---|
| The tf.TensorSpec corresponding to this instance. ||

<br />

### `to_tensor_spec`

[View source](https://github.com/tensorflow/datasets/blob/v4.9.10/tensorflow_datasets/core/features/feature.py#L172-L185)

    to_tensor_spec() -> tf.TensorSpec

Converts this TensorInfo instance to a tf.TensorSpec.

Note that there is a bug (b/227584124) around RaggedTensorSpec, so the
output for sequences of sequences may not be correct.

<br />

<br />

<br />

| Returns ||
|---|---|
| The tf.TensorSpec corresponding to this instance. ||

<br />

### `__eq__`

[View source](https://github.com/tensorflow/datasets/blob/v4.9.10/tensorflow_datasets/core/features/feature.py#L213-L222)

    __eq__(
        other
    )

Equality.