# tf.compat.v1.to_double

<br />

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

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

    tf.compat.v1.to_double(
        x, name='ToDouble'
    )

<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.double)`](https://www.tensorflow.org/versions/r2.13/api_docs/python/tf/cast). There are no further issues with eager execution or
tf.function.

Before:

    tf.compat.v1.to_double(tf.constant(3.14, dtype=tf.float32))
    <tf.Tensor: shape=(), dtype=float64, numpy=3.14>

After:

    tf.cast(tf.constant(3.14, dtype=tf.float32), tf.double)
    <tf.Tensor: shape=(), dtype=float64, numpy=3.14>

<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.13/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 `float64`. ||

<br />

<br />

<br />

<br />

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

<br />