tf.keras.ops.matrix_power
Stay organized with collections
Save and categorize content based on your preferences.
Note: This API is new and only available via pip install tf-nightly.
Raise a square matrix to the (integer) power n.
tf . keras . ops . matrix_power (
x , n
)
For positive integers n, the power is computed by repeated matrix
squarings and matrix multiplications. If n == 0, the identity matrix
of the same shape as x is returned. If n < 0, the inverse is
computed and then raised to the abs(n).
Args
x
Input tensor of shape (..., M, M).
n
Exponent (integer).
Returns
A tensor of shape (..., M, M) representing x**n.
Example:
x = keras . ops . convert_to_tensor ([[ 1. , 2. ], [ 3. , 4. ]])
matrix_power ( x , 3 )
array ([[ 37. , 54. ],
[ 81. , 118. ]], dtype = float32 )
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."],[],[]]