Keras.backend.batch_dot API 纪要

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)
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容