import time
import tensorflow as tf
tf.compat.v1.disable_eager_execution()
#%% 平均2.7秒。 发现conda 创建tf1.15 速度非常慢,应该环境配置有问题
A = tf.linalg.svd(tf.random.normal([2000,2000]))
with tf.compat.v1.Session() as sess:
sess.run(tf.compat.v1.global_variables_initializer())
print(time.localtime())
y= sess.run(A)
print(time.localtime())
y= sess.run(A)
print(time.localtime())
y= sess.run(A)
print(time.localtime())
#%%
from pylab import svd, randn
import torch
# mac 16 的运行速度
%time Us, Ds, Vs = svd(randn(2000,2000))
# 2.6秒
%time Us, Ds, Vs = torch.svd(torch.randn(2000, 2000))
# 1.6秒
import jax.numpy as jnp
%time u,d,v = jnp.linalg.svd(randn(2000, 2000))
# 1秒
标签:sess,SVD,计算速度,2000,测试,time,tf,import,svd
From: https://www.cnblogs.com/bregman/p/17405492.html