美文网首页
Keras.backend.batch_dot API 纪要

Keras.backend.batch_dot API 纪要

作者: HITMiner | 来源:发表于2018-11-08 11:36 被阅读204次

    K.batch_dot

    • 传入参数

      1. x, Keras tensor or variable with ndim >= 2
      2. y, Keras tensor or variable with ndim >= 2.
      3. axis, 整数或者tuple(int, int)或者None
        axis是元组时,axis[0]表示x参数参与dot的维;axis[1]表示y参数参与dot的维。
        axis是整数时, 表示xy参与dot的维
        axis是None时,表示x参与dot的维是倒数第一个维,y参数dot的参数是倒数第一个维(ndim(y) == 2时)或倒数第二个维 (ndim(y) != 2时)
    • K.batch_dot 不对第一维(batch)做dot

    • 返回参数

      1. A tensor with shape equal to the concatenation of x's shape
        (less the dimension that was summed over) and y's shape
        (less the batch dimension and the dimension that was summed over).
        If the final rank is 1, we reshape it to (batch_size, 1)
    • 例子

      1. Shape inference:
        Let x's shape be (100, 20) and y's shape be (100, 30, 20).
        If axes is (1, 2), to find the output shape of resultant tensor,
        loop through each dimension in x's shape and y's shape:

        • x.shape[0] : 100 : append to output shape
        • x.shape[1] : 20 : do not append to output shape,
          dimension 1 of x has been summed over. (dot_axes[0] = 1)
        • y.shape[0] : 100 : do not append to output shape,
          always ignore first dimension of y
        • y.shape[1] : 30 : append to output shape
        • y.shape[2] : 20 : do not append to output shape,
          dimension 2 of y has been summed over. (dot_axes[1] = 2)
          output_shape = (100, 30)

    相关文章

      网友评论

          本文标题:Keras.backend.batch_dot API 纪要

          本文链接:https://www.haomeiwen.com/subject/gnadxqtx.html