這篇文章主要介紹TensorFlow2.0矩陣與向量如何實現加減乘操作,文中介紹的非常詳細,具有一定的參考價值,感興趣的小伙伴們一定要看完!
1、矩陣加法使用
a = np.random.random((3,3)) b = np.random.randint(0,9,(3,3)) ad = tf.add(a,b)
2、矩陣乘法注意
# tensorflow 使用矩陣乘法都必須使用相同類型的數據,否則報錯。 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、數的除法
d = tf.divide(9*2,3) print(d.numpy())
以上是“TensorFlow2.0矩陣與向量如何實現加減乘操作”這篇文章的所有內容,感謝各位的閱讀!希望分享的內容對大家有幫助,更多相關知識,歡迎關注億速云行業資訊頻道!
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。