# tf.compat.v1.to_complex64

<br />

|---|
| [![](https://www.tensorflow.org/images/GitHub-Mark-32px.png) View source on GitHub](https://github.com/tensorflow/tensorflow/blob/v2.14.0/tensorflow/python/ops/math_ops.py#L1310-L1347) |

Casts a tensor to type `complex64`. (deprecated)

    tf.compat.v1.to_complex64(
        x, name='ToComplex64'
    )

<br />

## Migrate to TF2

<br />

> [!CAUTION]
> **Caution:** This API was designed for TensorFlow v1. Continue reading for details on how to migrate from this API to a native TensorFlow v2 equivalent. See the [TensorFlow v1 to TensorFlow v2 migration guide](https://www.tensorflow.org/guide/migrate) for instructions on how to migrate the rest of your code.

This name was deprecated and removed in TF2, but has an exact replacement
[`tf.cast(..., tf.complex64)`](https://www.tensorflow.org/versions/r2.14/api_docs/python/tf/cast). There are no further issues with eager execution
or tf.function.

Before:

    tf.compat.v1.to_complex64(tf.constant(1. + 2.j, dtype=tf.complex128))
    <tf.Tensor: shape=(), dtype=complex64, numpy=(1+2j)>

After:

    tf.cast(tf.constant(1. + 2.j, dtype=tf.complex128), tf.complex64)
    <tf.Tensor: shape=(), dtype=complex64, numpy=(1+2j)>

<br />

<br />

## Description

> [!WARNING]
> **Deprecated:** THIS FUNCTION IS DEPRECATED. It will be removed in a future version. Instructions for updating: Use [`tf.cast`](https://www.tensorflow.org/versions/r2.14/api_docs/python/tf/cast) instead.

<br />

<br />

<br />

| ## Args ||
|---|---|
| `x` | A `Tensor` or `SparseTensor` or `IndexedSlices`. |
| `name` | A name for the operation (optional). |

<br />

<br />

<br />

<br />

| ## Returns ||
|---|---|
| A `Tensor` or `SparseTensor` or `IndexedSlices` with same shape as `x` with type `complex64`. ||

<br />

<br />

<br />

<br />

| ## Raises ||
|---|---|
| `TypeError` | If `x` cannot be cast to the `complex64`. |

<br />