tf.keras.KerasTensor
Stay organized with collections
Save and categorize content based on your preferences.
Symbolic tensor -- encapsulates a shape and a dtype.
tf.keras.KerasTensor(
shape,
dtype='float32',
sparse=False,
record_history=True,
name=None
)
You can use KerasTensor
instances to build computation
graphs of Keras operations, such as keras.Function
objects or Functional keras.models.Model
objects.
Example:
x = keras.KerasTensor(shape=(3, 4), dtype="float32")
x.shape
(3, 4)
x.dtype
float32
Calling a Keras operation (including a layer or a model)
on a KerasTensor
instance will return another KerasTensor
instance with the appropriate shape and dtype. This is
called a "symbolic call" (since there is no actual data
involved). The computation of the correct output shape and
dtype is called "static shape inference".
Methods
reshape
View source
reshape(
newshape
)
squeeze
View source
squeeze(
axis=None
)
__abs__
View source
__abs__()
__add__
View source
__add__(
other
)
__and__
View source
__and__(
other
)
__array__
View source
__array__()
__bool__
View source
__bool__()
__div__
View source
__div__(
other
)
__floordiv__
View source
__floordiv__(
other
)
__ge__
View source
__ge__(
other
)
Return self>=value.
__getitem__
View source
__getitem__(
key
)
__gt__
View source
__gt__(
other
)
Return self>value.
__invert__
View source
__invert__()
__iter__
View source
__iter__()
__le__
View source
__le__(
other
)
Return self<=value.
__lt__
View source
__lt__(
other
)
Return self<value.
__matmul__
View source
__matmul__(
other
)
__mod__
View source
__mod__(
other
)
__mul__
View source
__mul__(
other
)
__ne__
View source
__ne__(
other
)
Return self!=value.
__neg__
View source
__neg__()
__or__
View source
__or__(
other
)
__pow__
View source
__pow__(
other
)
__radd__
View source
__radd__(
other
)
__rand__
View source
__rand__(
other
)
__rdiv__
View source
__rdiv__(
other
)
__rfloordiv__
View source
__rfloordiv__(
other
)
__rmatmul__
View source
__rmatmul__(
other
)
__rmod__
View source
__rmod__(
other
)
__rmul__
View source
__rmul__(
other
)
__ror__
View source
__ror__(
other
)
__rpow__
View source
__rpow__(
other
)
__rsub__
View source
__rsub__(
other
)
__rtruediv__
View source
__rtruediv__(
other
)
__rxor__
View source
__rxor__(
other
)
__sub__
View source
__sub__(
other
)
__truediv__
View source
__truediv__(
other
)
__xor__
View source
__xor__(
other
)
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. Some content is licensed under the numpy license.
Last updated 2024-06-07 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 2024-06-07 UTC."],[],[],null,["# tf.keras.KerasTensor\n\n\u003cbr /\u003e\n\n|---------------------------------------------------------------------------------------------------------------------------|\n| [View source on GitHub](https://github.com/keras-team/keras/tree/v3.3.3/keras/src/backend/common/keras_tensor.py#L6-L290) |\n\nSymbolic tensor -- encapsulates a shape and a dtype.\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.keras.KerasTensor`](https://www.tensorflow.org/api_docs/python/tf/keras/KerasTensor)\n\n\u003cbr /\u003e\n\n tf.keras.KerasTensor(\n shape,\n dtype='float32',\n sparse=False,\n record_history=True,\n name=None\n )\n\nYou can use `KerasTensor` instances to build computation\ngraphs of Keras operations, such as [`keras.Function`](../../tf/keras/Function)\nobjects or Functional [`keras.models.Model`](../../tf/keras/Model) objects.\n\n#### Example:\n\n x = keras.KerasTensor(shape=(3, 4), dtype=\"float32\")\n x.shape\n (3, 4)\n x.dtype\n float32\n\nCalling a Keras operation (including a layer or a model)\non a `KerasTensor` instance will return another `KerasTensor`\ninstance with the appropriate shape and dtype. This is\ncalled a \"symbolic call\" (since there is no actual data\ninvolved). The computation of the correct output shape and\ndtype is called \"static shape inference\".\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Attributes ---------- ||\n|--------|---------------|\n| `ndim` | \u003cbr /\u003e \u003cbr /\u003e |\n\n\u003cbr /\u003e\n\nMethods\n-------\n\n### `reshape`\n\n[View source](https://github.com/keras-team/keras/tree/v3.3.3/keras/src/backend/common/keras_tensor.py#L50-L53) \n\n reshape(\n newshape\n )\n\n### `squeeze`\n\n[View source](https://github.com/keras-team/keras/tree/v3.3.3/keras/src/backend/common/keras_tensor.py#L55-L58) \n\n squeeze(\n axis=None\n )\n\n### `__abs__`\n\n[View source](https://github.com/keras-team/keras/tree/v3.3.3/keras/src/backend/common/keras_tensor.py#L192-L195) \n\n __abs__()\n\n### `__add__`\n\n[View source](https://github.com/keras-team/keras/tree/v3.3.3/keras/src/backend/common/keras_tensor.py#L127-L130) \n\n __add__(\n other\n )\n\n### `__and__`\n\n[View source](https://github.com/keras-team/keras/tree/v3.3.3/keras/src/backend/common/keras_tensor.py#L252-L255) \n\n __and__(\n other\n )\n\n### `__array__`\n\n[View source](https://github.com/keras-team/keras/tree/v3.3.3/keras/src/backend/common/keras_tensor.py#L60-L65) \n\n __array__()\n\n### `__bool__`\n\n[View source](https://github.com/keras-team/keras/tree/v3.3.3/keras/src/backend/common/keras_tensor.py#L124-L125) \n\n __bool__()\n\n### `__div__`\n\n[View source](https://github.com/keras-team/keras/tree/v3.3.3/keras/src/backend/common/keras_tensor.py#L167-L170) \n\n __div__(\n other\n )\n\n### `__floordiv__`\n\n[View source](https://github.com/keras-team/keras/tree/v3.3.3/keras/src/backend/common/keras_tensor.py#L207-L210) \n\n __floordiv__(\n other\n )\n\n### `__ge__`\n\n[View source](https://github.com/keras-team/keras/tree/v3.3.3/keras/src/backend/common/keras_tensor.py#L242-L245) \n\n __ge__(\n other\n )\n\nReturn self\\\u003e=value.\n\n### `__getitem__`\n\n[View source](https://github.com/keras-team/keras/tree/v3.3.3/keras/src/backend/common/keras_tensor.py#L287-L290) \n\n __getitem__(\n key\n )\n\n### `__gt__`\n\n[View source](https://github.com/keras-team/keras/tree/v3.3.3/keras/src/backend/common/keras_tensor.py#L237-L240) \n\n __gt__(\n other\n )\n\nReturn self\\\u003evalue.\n\n### `__invert__`\n\n[View source](https://github.com/keras-team/keras/tree/v3.3.3/keras/src/backend/common/keras_tensor.py#L272-L275) \n\n __invert__()\n\n### `__iter__`\n\n[View source](https://github.com/keras-team/keras/tree/v3.3.3/keras/src/backend/common/keras_tensor.py#L119-L122) \n\n __iter__()\n\n### `__le__`\n\n[View source](https://github.com/keras-team/keras/tree/v3.3.3/keras/src/backend/common/keras_tensor.py#L232-L235) \n\n __le__(\n other\n )\n\nReturn self\\\u003c=value.\n\n### `__lt__`\n\n[View source](https://github.com/keras-team/keras/tree/v3.3.3/keras/src/backend/common/keras_tensor.py#L227-L230) \n\n __lt__(\n other\n )\n\nReturn self\\\u003cvalue.\n\n### `__matmul__`\n\n[View source](https://github.com/keras-team/keras/tree/v3.3.3/keras/src/backend/common/keras_tensor.py#L157-L160) \n\n __matmul__(\n other\n )\n\n### `__mod__`\n\n[View source](https://github.com/keras-team/keras/tree/v3.3.3/keras/src/backend/common/keras_tensor.py#L217-L220) \n\n __mod__(\n other\n )\n\n### `__mul__`\n\n[View source](https://github.com/keras-team/keras/tree/v3.3.3/keras/src/backend/common/keras_tensor.py#L147-L150) \n\n __mul__(\n other\n )\n\n### `__ne__`\n\n[View source](https://github.com/keras-team/keras/tree/v3.3.3/keras/src/backend/common/keras_tensor.py#L247-L250) \n\n __ne__(\n other\n )\n\nReturn self!=value.\n\n### `__neg__`\n\n[View source](https://github.com/keras-team/keras/tree/v3.3.3/keras/src/backend/common/keras_tensor.py#L187-L190) \n\n __neg__()\n\n### `__or__`\n\n[View source](https://github.com/keras-team/keras/tree/v3.3.3/keras/src/backend/common/keras_tensor.py#L262-L265) \n\n __or__(\n other\n )\n\n### `__pow__`\n\n[View source](https://github.com/keras-team/keras/tree/v3.3.3/keras/src/backend/common/keras_tensor.py#L197-L200) \n\n __pow__(\n other\n )\n\n### `__radd__`\n\n[View source](https://github.com/keras-team/keras/tree/v3.3.3/keras/src/backend/common/keras_tensor.py#L132-L135) \n\n __radd__(\n other\n )\n\n### `__rand__`\n\n[View source](https://github.com/keras-team/keras/tree/v3.3.3/keras/src/backend/common/keras_tensor.py#L257-L260) \n\n __rand__(\n other\n )\n\n### `__rdiv__`\n\n[View source](https://github.com/keras-team/keras/tree/v3.3.3/keras/src/backend/common/keras_tensor.py#L172-L175) \n\n __rdiv__(\n other\n )\n\n### `__rfloordiv__`\n\n[View source](https://github.com/keras-team/keras/tree/v3.3.3/keras/src/backend/common/keras_tensor.py#L212-L215) \n\n __rfloordiv__(\n other\n )\n\n### `__rmatmul__`\n\n[View source](https://github.com/keras-team/keras/tree/v3.3.3/keras/src/backend/common/keras_tensor.py#L162-L165) \n\n __rmatmul__(\n other\n )\n\n### `__rmod__`\n\n[View source](https://github.com/keras-team/keras/tree/v3.3.3/keras/src/backend/common/keras_tensor.py#L222-L225) \n\n __rmod__(\n other\n )\n\n### `__rmul__`\n\n[View source](https://github.com/keras-team/keras/tree/v3.3.3/keras/src/backend/common/keras_tensor.py#L152-L155) \n\n __rmul__(\n other\n )\n\n### `__ror__`\n\n[View source](https://github.com/keras-team/keras/tree/v3.3.3/keras/src/backend/common/keras_tensor.py#L267-L270) \n\n __ror__(\n other\n )\n\n### `__rpow__`\n\n[View source](https://github.com/keras-team/keras/tree/v3.3.3/keras/src/backend/common/keras_tensor.py#L202-L205) \n\n __rpow__(\n other\n )\n\n### `__rsub__`\n\n[View source](https://github.com/keras-team/keras/tree/v3.3.3/keras/src/backend/common/keras_tensor.py#L142-L145) \n\n __rsub__(\n other\n )\n\n### `__rtruediv__`\n\n[View source](https://github.com/keras-team/keras/tree/v3.3.3/keras/src/backend/common/keras_tensor.py#L182-L185) \n\n __rtruediv__(\n other\n )\n\n### `__rxor__`\n\n[View source](https://github.com/keras-team/keras/tree/v3.3.3/keras/src/backend/common/keras_tensor.py#L282-L285) \n\n __rxor__(\n other\n )\n\n### `__sub__`\n\n[View source](https://github.com/keras-team/keras/tree/v3.3.3/keras/src/backend/common/keras_tensor.py#L137-L140) \n\n __sub__(\n other\n )\n\n### `__truediv__`\n\n[View source](https://github.com/keras-team/keras/tree/v3.3.3/keras/src/backend/common/keras_tensor.py#L177-L180) \n\n __truediv__(\n other\n )\n\n### `__xor__`\n\n[View source](https://github.com/keras-team/keras/tree/v3.3.3/keras/src/backend/common/keras_tensor.py#L277-L280) \n\n __xor__(\n other\n )"]]