溫馨提示×

溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊×
其他方式登錄
點(diǎn)擊 登錄注冊 即表示同意《億速云用戶服務(wù)條款》

TensorFlow2.0矩陣與向量如何實(shí)現(xiàn)加減乘操作

發(fā)布時(shí)間:2021-08-23 10:14:58 來源:億速云 閱讀:177 作者:小新 欄目:開發(fā)技術(shù)

這篇文章主要介紹TensorFlow2.0矩陣與向量如何實(shí)現(xiàn)加減乘操作,文中介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們一定要看完!

1、矩陣加法使用

a = np.random.random((3,3))
b = np.random.randint(0,9,(3,3))
ad = tf.add(a,b)

2、矩陣乘法注意

# tensorflow 使用矩陣乘法都必須使用相同類型的數(shù)據(jù),否則報(bào)錯(cuò)。
a = np.random.random((5,3))
b = np.random.randint(0,9,(3,6))
c = tf.tensordot(a.astype(np.float),b.astype(np.float),axes=1)
print(c.numpy())

3、矩陣減法

a = np.random.random((3,3))
b = np.random.randint(0,9,(3,3))
ad = tf.subtract(a,b)

4、數(shù)的除法

d = tf.divide(9*2,3)
print(d.numpy())

以上是“TensorFlow2.0矩陣與向量如何實(shí)現(xiàn)加減乘操作”這篇文章的所有內(nèi)容,感謝各位的閱讀!希望分享的內(nèi)容對大家有幫助,更多相關(guān)知識(shí),歡迎關(guān)注億速云行業(yè)資訊頻道!

向AI問一下細(xì)節(jié)
AI