I am using eigendecomposition in Tensorflow and find that it is extremely slow. Here's the code to show Tensorflow's speed vs numpy and scipy:
import numpy as np
import scipy as sp
import tensorflow as tf
from time import time
A = np.random.randn(400, 400)
A_tf = tf.constant(A)
cur = time()
d, v = sp.linalg.eig(A)
print(f'sp: {time() - cur:4.2f} s')
cur = time()
d, v = np.linalg.eig(A)
print(f'np: {time() - cur:4.2f} s')
cur = time()
d, v = tf.linalg.eig(A_tf)
print(f'tf: {time() - cur:4.2f} s')
This gives the following output:
sp: 0.09 s
np: 0.08 s
tf: 5.04 s
Any ideas of what's up here?