format:multiply(x, y, name=None)
Args:
x: A `Tensor`. Must be one of the following types: `half`, `float32`, `float64`, `uint8`, `int8`, `uint16`, `int16`, `int32`, `int64`, `complex64`, `complex128`.
y: A `Tensor`. Must have the same type as `x`. (注意,这里强调了这两个相乘的数要有相同的数据类型,不然就会报错)
Returns x * y element-wise. (这里指multiply这个函数实现的是元素级别的相乘,也就是两个相乘的数元素各自相乘,而不是矩阵乘法,注意和tf.matmul区别)
import matplotlib.pyplot as plt import tensorflow as tf import numpy as np sess = tf.Session() print(sess.run(tf.multiply(2, 3) + 20))
=26