View source on GitHub |
Multiplies 2 tensors (and/or variables) and returns a tensor.
tf.keras.backend.dot(
x, y
)
When attempting to multiply a nD tensor
with a nD tensor, it reproduces the Theano behavior.
(e.g. (2, 3) * (4, 3, 5) -> (2, 4, 5)
)
x
: Tensor or variable.y
: Tensor or variable.A tensor, dot product of x
and y
.
x = tf.keras.backend.placeholder(shape=(2, 3)) y = tf.keras.backend.placeholder(shape=(3, 4)) xy = tf.keras.backend.dot(x, y) xy
x = tf.keras.backend.placeholder(shape=(32, 28, 3)) y = tf.keras.backend.placeholder(shape=(3, 4)) xy = tf.keras.backend.dot(x, y) xy
x = tf.keras.backend.random_uniform_variable(shape=(2, 3), low=0, high=1) y = tf.keras.backend.ones((4, 3, 5)) xy = tf.keras.backend.dot(x, y) tf.keras.backend.int_shape(xy) (2, 4, 5)