TensorFlow函數(shù)教程:tf.keras.backend.dot

2019-03-10 13:21 更新

tf.keras.backend.dot函數(shù)

tf.keras.backend.dot(
    x,
    y
)

定義在:tensorflow/python/keras/backend.py。

將2個張量(或變量)相乘并返回張量。

當(dāng)試圖將nD張量與nD張量相乘時,它會再現(xiàn)Theano行為。(例如:(2, 3) * (4, 3, 5) -> (2, 4, 5))

參數(shù):

  • x:張量或變量。
  • y:張量或變量。

返回:

一個張量,xy的點積。

例子:

    # dot product between tensors
    >>> x = K.placeholder(shape=(2, 3))
    >>> y = K.placeholder(shape=(3, 4))
    >>> xy = K.dot(x, y)
    >>> xy
    <tf.Tensor 'MatMul_9:0' shape=(2, 4) dtype=float32>
    # dot product between tensors
    >>> x = K.placeholder(shape=(32, 28, 3))
    >>> y = K.placeholder(shape=(3, 4))
    >>> xy = K.dot(x, y)
    >>> xy
    <tf.Tensor 'MatMul_9:0' shape=(32, 28, 4) dtype=float32>
    # Theano-like behavior example
    >>> x = K.random_uniform_variable(shape=(2, 3), low=0, high=1)
    >>> y = K.ones((4, 3, 5))
    >>> xy = K.dot(x, y)
    >>> K.int_shape(xy)
    (2, 4, 5)
以上內(nèi)容是否對您有幫助:
在線筆記
App下載
App下載

掃描二維碼

下載編程獅App

公眾號
微信公眾號

編程獅公眾號