K.batch_dot
-
传入参数
-
x, Keras tensor or variable withndim >= 2 -
y, Keras tensor or variable withndim >= 2. -
axis, 整数或者tuple(int, int)或者None
axis是元组时,axis[0]表示x参数参与dot的维;axis[1]表示y参数参与dot的维。
axis是整数时, 表示x和y参与dot的维
axis是None时,表示x参与dot的维是倒数第一个维,y参数dot的参数是倒数第一个维(ndim(y) == 2时)或倒数第二个维 (ndim(y) != 2时)
-
K.batch_dot 不对第一维(batch)做dot
-
返回参数
- A tensor with shape equal to the concatenation of
x's shape
(less the dimension that was summed over) andy'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)
- A tensor with shape equal to the concatenation of
-
例子
-
Shape inference:
Letx's shape be(100, 20)andy's shape be(100, 30, 20).
Ifaxesis (1, 2), to find the output shape of resultant tensor,
loop through each dimension inx's shape andy's shape:-
x.shape[0]: 100 : append to output shape -
x.shape[1]: 20 : do not append to output shape,
dimension 1 ofxhas been summed over. (dot_axes[0]= 1) -
y.shape[0]: 100 : do not append to output shape,
always ignore first dimension ofy -
y.shape[1]: 30 : append to output shape -
y.shape[2]: 20 : do not append to output shape,
dimension 2 ofyhas been summed over. (dot_axes[1]= 2)
output_shape=(100, 30)
-
-