tf.keras.ops.view_as_real
Stay organized with collections
Save and categorize content based on your preferences.
Converts a complex tensor to a real tensor with shape (..., 2), where the last dimension represents the real and imaginary components.
tf.keras.ops.view_as_real(
x
)
Returns |
|
A real tensor where the last dimension contains the
real and imaginary parts.
|
Example:
import numpy as np
from keras import ops
<pre class="devsite-click-to-copy prettyprint lang-py">
<code class="devsite-terminal" data-terminal-prefix=">>>">complex_tensor = np.array([1 + 2j, 3 + 4j])</code>
<code class="devsite-terminal" data-terminal-prefix=">>>">real = ops.view_as_real(complex_tensor)</code>
<code class="devsite-terminal" data-terminal-prefix=">>>">real</code>
<code class="no-select nocode">array([[1., 2.],</code>
<code class="no-select nocode"> [3., 4.]])</code>
</pre>
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 2026-10-31 UTC.
[null,null,["Last updated 2026-10-31 UTC."],[],[]]