<br />

|---|
| [![](https://www.tensorflow.org/images/GitHub-Mark-32px.png) View source on GitHub](https://github.com/keras-team/keras/tree/v3.15.1/keras/src/backend/common/keras_tensor.py#L6-L399) |

Symbolic tensor -- encapsulates a shape and a dtype.

#### View aliases


**Compat aliases for migration**

See
[Migration guide](https://www.tensorflow.org/guide/migrate) for
more details.

[`tf.compat.v1.keras.KerasTensor`](https://www.tensorflow.org/api_docs/python/tf/keras/KerasTensor)

<br />

    tf.keras.KerasTensor(
        shape,
        dtype='float32',
        sparse=False,
        ragged=False,
        record_history=True,
        name=None,
        **kwargs
    )

You can use `KerasTensor` instances to build computation
graphs of Keras operations, such as [`keras.Function`](https://www.tensorflow.org/api_docs/python/tf/keras/Function)
objects or Functional [`keras.models.Model`](https://www.tensorflow.org/api_docs/python/tf/keras/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".

<br />

<br />

<br />

| ## Attributes ||
|---|---|
| `dtype` | <br /> <br /> |
| `ndim` | <br /> <br /> |
| `ragged` | <br /> <br /> |
| `ragged_rank` | <br /> <br /> |
| `row_splits_dtype` | <br /> <br /> |
| `shape` | <br /> <br /> |
| `sparse` | <br /> <br /> |

<br />

## Methods

### `reshape`

[View source](https://github.com/keras-team/keras/tree/v3.15.1/keras/src/backend/common/keras_tensor.py#L139-L142)

    reshape(
        newshape
    )

### `squeeze`

[View source](https://github.com/keras-team/keras/tree/v3.15.1/keras/src/backend/common/keras_tensor.py#L144-L147)

    squeeze(
        axis=None
    )

### `__abs__`

[View source](https://github.com/keras-team/keras/tree/v3.15.1/keras/src/backend/common/keras_tensor.py#L295-L298)

    __abs__()

### `__add__`

[View source](https://github.com/keras-team/keras/tree/v3.15.1/keras/src/backend/common/keras_tensor.py#L230-L233)

    __add__(
        other
    )

### `__and__`

[View source](https://github.com/keras-team/keras/tree/v3.15.1/keras/src/backend/common/keras_tensor.py#L355-L358)

    __and__(
        other
    )

### `__array__`

[View source](https://github.com/keras-team/keras/tree/v3.15.1/keras/src/backend/common/keras_tensor.py#L163-L168)

    __array__()

### `__bool__`

[View source](https://github.com/keras-team/keras/tree/v3.15.1/keras/src/backend/common/keras_tensor.py#L227-L228)

    __bool__()

### `__div__`

[View source](https://github.com/keras-team/keras/tree/v3.15.1/keras/src/backend/common/keras_tensor.py#L270-L273)

    __div__(
        other
    )

### `__floordiv__`

[View source](https://github.com/keras-team/keras/tree/v3.15.1/keras/src/backend/common/keras_tensor.py#L310-L313)

    __floordiv__(
        other
    )

### `__ge__`

[View source](https://github.com/keras-team/keras/tree/v3.15.1/keras/src/backend/common/keras_tensor.py#L345-L348)

    __ge__(
        other
    )

Return self\>=value.

### `__getitem__`

[View source](https://github.com/keras-team/keras/tree/v3.15.1/keras/src/backend/common/keras_tensor.py#L390-L393)

    __getitem__(
        key
    )

### `__gt__`

[View source](https://github.com/keras-team/keras/tree/v3.15.1/keras/src/backend/common/keras_tensor.py#L340-L343)

    __gt__(
        other
    )

Return self\>value.

### `__invert__`

[View source](https://github.com/keras-team/keras/tree/v3.15.1/keras/src/backend/common/keras_tensor.py#L375-L378)

    __invert__()

### `__iter__`

[View source](https://github.com/keras-team/keras/tree/v3.15.1/keras/src/backend/common/keras_tensor.py#L222-L225)

    __iter__()

### `__le__`

[View source](https://github.com/keras-team/keras/tree/v3.15.1/keras/src/backend/common/keras_tensor.py#L335-L338)

    __le__(
        other
    )

Return self\<=value.

### `__lt__`

[View source](https://github.com/keras-team/keras/tree/v3.15.1/keras/src/backend/common/keras_tensor.py#L330-L333)

    __lt__(
        other
    )

Return self\<value.

### `__matmul__`

[View source](https://github.com/keras-team/keras/tree/v3.15.1/keras/src/backend/common/keras_tensor.py#L260-L263)

    __matmul__(
        other
    )

### `__mod__`

[View source](https://github.com/keras-team/keras/tree/v3.15.1/keras/src/backend/common/keras_tensor.py#L320-L323)

    __mod__(
        other
    )

### `__mul__`

[View source](https://github.com/keras-team/keras/tree/v3.15.1/keras/src/backend/common/keras_tensor.py#L250-L253)

    __mul__(
        other
    )

### `__ne__`

[View source](https://github.com/keras-team/keras/tree/v3.15.1/keras/src/backend/common/keras_tensor.py#L350-L353)

    __ne__(
        other
    )

Return self!=value.

### `__neg__`

[View source](https://github.com/keras-team/keras/tree/v3.15.1/keras/src/backend/common/keras_tensor.py#L290-L293)

    __neg__()

### `__or__`

[View source](https://github.com/keras-team/keras/tree/v3.15.1/keras/src/backend/common/keras_tensor.py#L365-L368)

    __or__(
        other
    )

Return self\|value.

### `__pow__`

[View source](https://github.com/keras-team/keras/tree/v3.15.1/keras/src/backend/common/keras_tensor.py#L300-L303)

    __pow__(
        other
    )

### `__radd__`

[View source](https://github.com/keras-team/keras/tree/v3.15.1/keras/src/backend/common/keras_tensor.py#L235-L238)

    __radd__(
        other
    )

### `__rand__`

[View source](https://github.com/keras-team/keras/tree/v3.15.1/keras/src/backend/common/keras_tensor.py#L360-L363)

    __rand__(
        other
    )

### `__rdiv__`

[View source](https://github.com/keras-team/keras/tree/v3.15.1/keras/src/backend/common/keras_tensor.py#L275-L278)

    __rdiv__(
        other
    )

### `__rfloordiv__`

[View source](https://github.com/keras-team/keras/tree/v3.15.1/keras/src/backend/common/keras_tensor.py#L315-L318)

    __rfloordiv__(
        other
    )

### `__rmatmul__`

[View source](https://github.com/keras-team/keras/tree/v3.15.1/keras/src/backend/common/keras_tensor.py#L265-L268)

    __rmatmul__(
        other
    )

### `__rmod__`

[View source](https://github.com/keras-team/keras/tree/v3.15.1/keras/src/backend/common/keras_tensor.py#L325-L328)

    __rmod__(
        other
    )

### `__rmul__`

[View source](https://github.com/keras-team/keras/tree/v3.15.1/keras/src/backend/common/keras_tensor.py#L255-L258)

    __rmul__(
        other
    )

### `__ror__`

[View source](https://github.com/keras-team/keras/tree/v3.15.1/keras/src/backend/common/keras_tensor.py#L370-L373)

    __ror__(
        other
    )

Return value\|self.

### `__rpow__`

[View source](https://github.com/keras-team/keras/tree/v3.15.1/keras/src/backend/common/keras_tensor.py#L305-L308)

    __rpow__(
        other
    )

### `__rsub__`

[View source](https://github.com/keras-team/keras/tree/v3.15.1/keras/src/backend/common/keras_tensor.py#L245-L248)

    __rsub__(
        other
    )

### `__rtruediv__`

[View source](https://github.com/keras-team/keras/tree/v3.15.1/keras/src/backend/common/keras_tensor.py#L285-L288)

    __rtruediv__(
        other
    )

### `__rxor__`

[View source](https://github.com/keras-team/keras/tree/v3.15.1/keras/src/backend/common/keras_tensor.py#L385-L388)

    __rxor__(
        other
    )

### `__sub__`

[View source](https://github.com/keras-team/keras/tree/v3.15.1/keras/src/backend/common/keras_tensor.py#L240-L243)

    __sub__(
        other
    )

### `__truediv__`

[View source](https://github.com/keras-team/keras/tree/v3.15.1/keras/src/backend/common/keras_tensor.py#L280-L283)

    __truediv__(
        other
    )

### `__xor__`

[View source](https://github.com/keras-team/keras/tree/v3.15.1/keras/src/backend/common/keras_tensor.py#L380-L383)

    __xor__(
        other
    )