<br />

> [!NOTE]
> **Note:** This API is new and only available via `pip install tf-nightly`.

|---|
| [![](https://www.tensorflow.org/images/GitHub-Mark-32px.png) View source on GitHub](https://github.com/keras-team/keras/tree/master/keras/src/ops/numpy.py#L2178-L2200) |

Compose a value from the magnitude of `x1` and the sign of `x2`.

#### View aliases


**Main aliases**

[`tf.keras.ops.numpy.copysign`](https://www.tensorflow.org/api_docs/python/tf/keras/ops/copysign.md.txt)

<br />

```python
tf.keras.ops.copysign(
    x1, x2
)
```

The sign of zero is taken into account, so an `x2` of `-0.0` gives a
negative result and an `x2` of `0.0` gives a positive one.

<br />

<br />

<br />

| ## Args ||
|---|---|
| `x1` | Input tensor providing the magnitude. |
| `x2` | Input tensor providing the sign. |

<br />

<br />

<br />

<br />

| ## Returns ||
|---|---|
| Output tensor with the magnitude of `x1` and the sign of `x2`. ||

<br />

#### Example:

```python
x1 = keras.ops.convert_to_tensor([-1.0, 2.0, -3.0])
x2 = keras.ops.convert_to_tensor([1.0, -1.0, -0.0])
keras.ops.copysign(x1, x2)
array([ 1., -2., -3.], dtype=float32)
```