tensorflow API: tf.multiply

tf.multiply:

(1) The multiply function implements element-level multiplication, that is, the two multiplied number elements are multiplied by each other.

x=tf.constant([[1.0,2.0,3.0],[1.0,2.0,3.0],[1.0,2.0,3.0]])  
y=tf.constant([[1 ,0 ,1.0],[2,0,1.0],[3 ,0,1.0]])
#注意这里这里x,y要有相同的数据类型,不然就会因为数据类型不匹配而出错
z=tf.multiply(x,y)
with tf.Session() as sess:  
    print(sess.run(z))

Output: [[1. 0. 3.]
[2. 0. 3.]
[3. 0. 3.]]

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325814908&siteId=291194637