tfds.features.TensorInfo
Stay organized with collections
Save and categorize content based on your preferences.
Structure containing info on the 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
)
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 dimension.
|
dataset_lvl
|
int , if >0, nesting level of a tfds.features.Dataset .
|
Attributes |
dataset_lvl
|
|
default_value
|
|
dtype
|
Return the TensorFlow DType of this TensorInfo.
|
np_dtype
|
|
numpy_dtype
|
|
sequence_rank
|
|
shape
|
|
tf_dtype
|
|
Methods
copy_from
View source
@classmethod
copy_from(
tensor_info: TensorInfo
) -> TensorInfo
Copy constructor.
from_tensor_spec
View source
@classmethod
from_tensor_spec(
tensor_spec: tf.TensorSpec
) -> TensorInfo
to_tensor_spec
View source
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.
Returns |
The tf.TensorSpec corresponding to this instance.
|
__eq__
View source
__eq__(
other
)
Equality.
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2024-04-26 UTC.
[null,null,["Last updated 2024-04-26 UTC."],[],[],null,["# tfds.features.TensorInfo\n\n\u003cbr /\u003e\n\n|-----------------------------------------------------------------------------------------------------------------------------------|\n| [View source on GitHub](https://github.com/tensorflow/datasets/blob/v4.9.3/tensorflow_datasets/core/features/feature.py#L78-L178) |\n\nStructure containing info on the [`tf.Tensor`](https://www.tensorflow.org/api_docs/python/tf/Tensor) shape/dtype. \n\n tfds.features.TensorInfo(\n shape: Shape,\n dtype: type_utils.TfdsDType,\n default_value=None,\n sequence_rank: Optional[int] = None,\n dataset_lvl: int = 0\n )\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Args ---- ||\n|-----------------|---------------------------------------------------------------------------------------------------------------------------|\n| `shape` | `tuple[int]`, shape of the tensor. |\n| `dtype` | Tensor DType that will be converted to NumPy DType. |\n| `default_value` | Used for retrocompatibility with previous files if a new field is added to provide a default value when reading the file. |\n| `sequence_rank` | `int`, Number of [`tfds.features.Sequence`](../../tfds/features/Sequence) dimension. |\n| `dataset_lvl` | `int`, if \\\u003e0, nesting level of a [`tfds.features.Dataset`](../../tfds/features/Dataset). |\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Attributes ---------- ||\n|-----------------|-------------------------------------------------|\n| `dataset_lvl` | \u003cbr /\u003e \u003cbr /\u003e |\n| `default_value` | \u003cbr /\u003e \u003cbr /\u003e |\n| `dtype` | Return the TensorFlow DType of this TensorInfo. |\n| `np_dtype` | \u003cbr /\u003e \u003cbr /\u003e |\n| `numpy_dtype` | \u003cbr /\u003e \u003cbr /\u003e |\n| `sequence_rank` | \u003cbr /\u003e \u003cbr /\u003e |\n| `shape` | \u003cbr /\u003e \u003cbr /\u003e |\n| `tf_dtype` | \u003cbr /\u003e \u003cbr /\u003e |\n\n\u003cbr /\u003e\n\nMethods\n-------\n\n### `copy_from`\n\n[View source](https://github.com/tensorflow/datasets/blob/v4.9.3/tensorflow_datasets/core/features/feature.py#L120-L129) \n\n @classmethod\n copy_from(\n tensor_info: TensorInfo\n ) -\u003e TensorInfo\n\nCopy constructor.\n\n### `from_tensor_spec`\n\n[View source](https://github.com/tensorflow/datasets/blob/v4.9.3/tensorflow_datasets/core/features/feature.py#L131-L136) \n\n @classmethod\n from_tensor_spec(\n tensor_spec: tf.TensorSpec\n ) -\u003e TensorInfo\n\n### `to_tensor_spec`\n\n[View source](https://github.com/tensorflow/datasets/blob/v4.9.3/tensorflow_datasets/core/features/feature.py#L138-L151) \n\n to_tensor_spec() -\u003e tf.TensorSpec\n\nConverts this TensorInfo instance to a tf.TensorSpec.\n\nNote that there is a bug (b/227584124) around RaggedTensorSpec, so the\noutput for sequences of sequences may not be correct.\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Returns ||\n|---|---|\n| The tf.TensorSpec corresponding to this instance. ||\n\n\u003cbr /\u003e\n\n### `__eq__`\n\n[View source](https://github.com/tensorflow/datasets/blob/v4.9.3/tensorflow_datasets/core/features/feature.py#L165-L171) \n\n __eq__(\n other\n )\n\nEquality."]]