TensorFlow2.0矩阵与向量的加减乘实例

今天小编就为大家分享一篇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矩阵与向量的加减乘实例就是小编分享给大家的全部内容了,希望能给大家一个参考,也希望大家多多支持html中文网。

以上就是TensorFlow2.0矩阵与向量的加减乘实例的详细内容,更多请关注0133技术站其它相关文章!

赞(0) 打赏
未经允许不得转载:0133技术站首页 » python