I have below code
import tensorflow as tf
X_tf = tf.Variable([[25, 2, 9], [5, 26, -5], [3, 7, -1]])
lambdas_X_tf, V_X_tf = tf.linalg.eig(X_tf)
when I execute it I get below error
File "C:\Users\u1.conda\envs\py39\lib\site-packages\tensorflow\python\util\traceback_utils.py", line 153, in error_handler raise e.with_traceback(filtered_tb) from None File "C:\Users\u1.conda\envs\py39\lib\site-packages\tensorflow\python\ops\linalg_ops.py", line 406, in eig e, v = gen_linalg_ops.eig(tensor, Tout=out_dtype, compute_v=True, name=name) UnboundLocalError: local variable 'out_dtype' referenced before assignment
What can be the reason?
You need to set dtype as float32
:
X_tf = tf.Variable([[25, 2, 9], [5, 26, -5], [3, 7, -1]], dtype=tf.float32)