亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

為什么張量流中的隨機數生成器 tf.random_uniform 比等效的 numpy 快得多

為什么張量流中的隨機數生成器 tf.random_uniform 比等效的 numpy 快得多

素胚勾勒不出你 2021-07-28 17:18:24
以下代碼是我用來測試性能的:import timeimport numpy as npimport tensorflow as tft = time.time()for i in range(400):    a = np.random.uniform(0,1,(1000,2000))print("np.random.uniform: {} seconds".format(time.time() - t))t = time.time()for i in range(400):    a = np.random.random((1000,2000))print("np.random.random:  {} seconds".format(time.time() - t))t = time.time()for i in range(400):    a = tf.random_uniform((1000,2000),dtype=tf.float64);print("tf.random_uniform: {} seconds".format(time.time() - t))所有這三個段都以雙精度 400 次生成均勻隨機的 1000*2000 矩陣。時間差異是驚人的。在我的 Mac 上,np.random.uniform: 10.4318959713 secondsnp.random.random:  8.76161003113 secondstf.random_uniform: 1.21312117577 seconds為什么 tensorflow 比 numpy 快得多?
查看完整描述

2 回答

  • 2 回答
  • 0 關注
  • 150 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號