tensorflow.linalg.eig throwing error UnboundLocalError: local variable 'out_dtype' referenced before assignment

Question:

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:Usersu1.condaenvspy39libsite-packagestensorflowpythonutiltraceback_utils.py", line 153, in error_handler
raise e.with_traceback(filtered_tb) from None
File "C:Usersu1.condaenvspy39libsite-packagestensorflowpythonopslinalg_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?

Asked By: Pritesh

||

Answers:

You need to set dtype as float32:

X_tf = tf.Variable([[25, 2, 9], [5, 26, -5], [3, 7, -1]], dtype=tf.float32) 
Answered By: V.M