python - tensorflow trace doesn't work -
i'm new tensorflow. have tensor x follows:
>>> x.eval() array([[1, 2, 3], [4, 5, 6], [7, 8, 9]], dtype=int32)
i want calculate trace of tensor, use tf.trace, throws error:
>>> tf.trace(x) traceback (most recent call last): file "<stdin>", line 1, in <module> attributeerror: 'module' object has no attribute 'trace'
how can fix it? many thanks
works me
import tensorflow tf x = tf.constant([[1, 2, 3],[4, 5, 6],[7, 8, 9]], dtype=tf.int32) sess = tf.interactivesession() x.eval() tf.trace(x).eval()
this prints
[[1 2 3] [4 5 6] [7 8 9]] 15
Comments
Post a Comment