tf.TypeSpec
Stay organized with collections
Save and categorize content based on your preferences.
Specifies a TensorFlow value type.
A tf.TypeSpec
provides metadata describing an object accepted or returned
by TensorFlow APIs. Concrete subclasses, such as tf.TensorSpec
and
tf.RaggedTensorSpec
, are used to describe different value types.
For example, tf.function
's input_signature
argument accepts a list
(or nested structure) of TypeSpec
s.
Creating new subclasses of TypeSpec (outside of TensorFlow core) is not
currently supported. In particular, we may make breaking changes to the
private methods and properties defined by this base class.
Attributes |
value_type
|
The Python type for values that are compatible with this TypeSpec.
|
Methods
is_compatible_with
View source
is_compatible_with(
spec_or_value
)
Returns true if spec_or_value
is compatible with this TypeSpec.
most_specific_compatible_type
View source
most_specific_compatible_type(
other
)
Returns the most specific TypeSpec compatible with self
and other
.
Raises |
ValueError
|
If there is no TypeSpec that is compatible with both self
and other .
|
__eq__
View source
__eq__(
other
)
Return self==value.
__ne__
View source
__ne__(
other
)
Return self!=value.
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 2020-10-01 UTC.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2020-10-01 UTC."],[],[],null,["# tf.TypeSpec\n\n\u003cbr /\u003e\n\n|---------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------------------------------|\n| [TensorFlow 1 version](/versions/r1.15/api_docs/python/tf/TypeSpec) | [View source on GitHub](https://github.com/tensorflow/tensorflow/blob/v2.0.0/tensorflow/python/framework/type_spec.py#L47-L414) |\n\nSpecifies a TensorFlow value type.\n\n#### View aliases\n\n\n**Compat aliases for migration**\n\nSee\n[Migration guide](https://www.tensorflow.org/guide/migrate) for\nmore details.\n\n[`tf.compat.v1.TypeSpec`](/api_docs/python/tf/TypeSpec), [`tf.compat.v1.data.experimental.Structure`](/api_docs/python/tf/TypeSpec)\n\n\u003cbr /\u003e\n\nA [`tf.TypeSpec`](../tf/TypeSpec) provides metadata describing an object accepted or returned\nby TensorFlow APIs. Concrete subclasses, such as [`tf.TensorSpec`](../tf/TensorSpec) and\n[`tf.RaggedTensorSpec`](../tf/RaggedTensorSpec), are used to describe different value types.\n\nFor example, [`tf.function`](../tf/function)'s `input_signature` argument accepts a list\n(or nested structure) of `TypeSpec`s.\n\nCreating new subclasses of TypeSpec (outside of TensorFlow core) is not\ncurrently supported. In particular, we may make breaking changes to the\nprivate methods and properties defined by this base class.\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Attributes ---------- ||\n|--------------|--------------------------------------------------------------------|\n| `value_type` | The Python type for values that are compatible with this TypeSpec. |\n\n\u003cbr /\u003e\n\nMethods\n-------\n\n### `is_compatible_with`\n\n[View source](https://github.com/tensorflow/tensorflow/blob/v2.0.0/tensorflow/python/framework/type_spec.py#L87-L102) \n\n is_compatible_with(\n spec_or_value\n )\n\nReturns true if `spec_or_value` is compatible with this TypeSpec.\n\n### `most_specific_compatible_type`\n\n[View source](https://github.com/tensorflow/tensorflow/blob/v2.0.0/tensorflow/python/framework/type_spec.py#L104-L126) \n\n most_specific_compatible_type(\n other\n )\n\nReturns the most specific TypeSpec compatible with `self` and `other`.\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Args ||\n|---------|---------------|\n| `other` | A `TypeSpec`. |\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Raises ||\n|--------------|--------------------------------------------------------------------------|\n| `ValueError` | If there is no TypeSpec that is compatible with both `self` and `other`. |\n\n\u003cbr /\u003e\n\n### `__eq__`\n\n[View source](https://github.com/tensorflow/tensorflow/blob/v2.0.0/tensorflow/python/framework/type_spec.py#L262-L265) \n\n __eq__(\n other\n )\n\nReturn self==value.\n\n### `__ne__`\n\n[View source](https://github.com/tensorflow/tensorflow/blob/v2.0.0/tensorflow/python/framework/type_spec.py#L267-L268) \n\n __ne__(\n other\n )\n\nReturn self!=value."]]