From 5786b050099edb287d707570467e0f62f22bfdbe Mon Sep 17 00:00:00 2001 From: ILCSFNO <138545608+ILCSFNO@users.noreply.github.com> Date: Fri, 3 Oct 2025 18:12:36 +0800 Subject: [PATCH 1/3] Add the description that `0` should not in the arg `axes` in `keras.layers.dot()` --- keras/src/layers/merging/dot.py | 1 + 1 file changed, 1 insertion(+) diff --git a/keras/src/layers/merging/dot.py b/keras/src/layers/merging/dot.py index 358ee768a04..cf75077c17a 100644 --- a/keras/src/layers/merging/dot.py +++ b/keras/src/layers/merging/dot.py @@ -363,6 +363,7 @@ def dot(inputs, axes=-1, **kwargs): inputs: A list of input tensors (at least 2). axes: Integer or tuple of integers, axis or axes along which to take the dot product. + In which `0` should not be included. normalize: Whether to L2-normalize samples along the dot product axis before taking the dot product. If set to `True`, then the output of the dot product From be714ad0fdc55e30105eb50c031b404c525fc233 Mon Sep 17 00:00:00 2001 From: ILCSFNO <138545608+ILCSFNO@users.noreply.github.com> Date: Fri, 3 Oct 2025 18:16:42 +0800 Subject: [PATCH 2/3] Update keras/src/layers/merging/dot.py Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com> --- keras/src/layers/merging/dot.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/keras/src/layers/merging/dot.py b/keras/src/layers/merging/dot.py index cf75077c17a..d6b2dea3379 100644 --- a/keras/src/layers/merging/dot.py +++ b/keras/src/layers/merging/dot.py @@ -363,7 +363,7 @@ def dot(inputs, axes=-1, **kwargs): inputs: A list of input tensors (at least 2). axes: Integer or tuple of integers, axis or axes along which to take the dot product. - In which `0` should not be included. + Note that axis `0` (the batch axis) cannot be included. normalize: Whether to L2-normalize samples along the dot product axis before taking the dot product. If set to `True`, then the output of the dot product From 12db5a779109b12d8073163623b18d5c0a9bf9bb Mon Sep 17 00:00:00 2001 From: ILCSFNO <138545608+ILCSFNO@users.noreply.github.com> Date: Mon, 6 Oct 2025 17:23:11 +0800 Subject: [PATCH 3/3] Update dot.py to fix the doc of `Dot` and `batch_dot` --- keras/src/layers/merging/dot.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/keras/src/layers/merging/dot.py b/keras/src/layers/merging/dot.py index d6b2dea3379..b49b965828c 100644 --- a/keras/src/layers/merging/dot.py +++ b/keras/src/layers/merging/dot.py @@ -41,6 +41,7 @@ def batch_dot(x, y, axes=None): axes: Tuple or list of integers with target dimensions, or single integer. The sizes of `x.shape[axes[0]]` and `y.shape[axes[1]]` should be equal. + Note that axis `0` (the batch axis) cannot be included. Returns: A tensor with shape equal to the concatenation of `x`'s shape @@ -226,7 +227,8 @@ class Dot(Merge): take the dot product. If a tuple, should be two integers corresponding to the desired axis from the first input and the desired axis from the second input, respectively. Note that the - size of the two selected axes must match. + size of the two selected axes must match, and that + axis `0` (the batch axis) cannot be included. normalize: Whether to L2-normalize samples along the dot product axis before taking the dot product. If set to `True`, then the output of the dot product is the cosine proximity