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())