tf.keras.ops.view_as_complex
Stay organized with collections
Save and categorize content based on your preferences.
Converts a real tensor with shape (..., 2) to a complex tensor, where the last dimension represents the real and imaginary components of a complex tensor.
tf.keras.ops.view_as_complex(
x
)
Args |
x
|
A real tensor with last dimension of size 2.
|
Returns |
A complex tensor with shape x.shape[:-1].
|
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=">>>">real_imag = np.array([[1.0, 2.0], [3.0, 4.0]])</code>
<code class="devsite-terminal" data-terminal-prefix=">>>">complex_tensor = ops.view_as_complex(real_imag)</code>
<code class="devsite-terminal" data-terminal-prefix=">>>">complex_tensor</code>
<code class="no-select nocode">array([1.+2.j, 3.+4.j])</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.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2026-10-31 UTC."],[],[]]