方法一、利用numpy.dot函数计算时间
import numpy as np
import time
A = np.random.rand(10000, 10000)
B = np.random.rand(10000, 10000)
start_time = time.time()
C = np.dot(A, B)
end_time = time.time()
print("方法1计算时间:", end_time - start_time)//3.94059681892395
方法二、利用numpy.multiply函数计算时间
import numpy as np
import time
A = np.random.rand(10000, 10000)
B = np.random.rand(10000, 10000)
start_time = time.time()
C = np.multiply(A, B).sum()
end_time = time.time()
print("方法2计算时间:", end_time - start_time)//9.166156768798828
上面是“利用NumPy计算时间(numpy.dot函数/numpy.multiply函数)”的全面内容,想了解更多关于 后端开发 内容,请继续关注web建站教程。
当前网址:https://ipkd.cn/webs_14030.html
猜你喜欢
声明:本站提供的所有资源部分来自互联网,如果有侵犯您的版权或其他权益,请发送到邮箱:admin@ipkd.cn,我们会在看到邮件的第一时间内为您处理!

帝国cms效果之会员登录之后之前显示的代码 












