0

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?

1 Answer 1

0

You need to set dtype as float32:

X_tf = tf.Variable([[25, 2, 9], [5, 26, -5], [3, 7, -1]], dtype=tf.float32) 
Sign up to request clarification or add additional context in comments.

1 Comment

worked. I wonder why TensorFlow did not through more meaningful error.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.