Skip to content

Add the description that 0 should not in the arg axes in keras.layers.dot() #21717

@ILCSFNO

Description

@ILCSFNO

Doc Issue

The doc of keras.layers.dot() shows its description as below:

axes: Integer or tuple of integers,
axis or axes along which to take the dot product.

For the repro below, I accept that it should raise error, but needed to be noted in the docstring, using tf v2.20.0-rc0-4-g72fbba3d20f 2.20.0 and keras latest:

Repro

import tensorflow as tf
import keras
tensor1 = tf.random.uniform((1, 10), maxval=100, minval=0, dtype=tf.float32)
tensor2 = tf.random.uniform((1, 10), maxval=100, minval=0, dtype=tf.float32)
dot_product = keras.layers.dot([tensor1, tensor2], axes=0)
print(dot_product)

Output

Cannot perform batch_dot over axis 0. If your inputs are not batched, add a dummy batch dimension to your inputs using keras.ops.expand_dims(x, 0)

Arguments received by Dot.call():
  • inputs=['tf.Tensor(shape=(1, 10), dtype=float32)', 'tf.Tensor(shape=(1, 10), dtype=float32)']

The related error is reported here:

# sanity checks
if 0 in axes:
raise ValueError(
"Cannot perform batch_dot over axis 0. "
"If your inputs are not batched, "
"add a dummy batch dimension to your "
"inputs using keras.ops.expand_dims(x, 0)"
)

Thanks a lot!

Metadata

Metadata

Labels

type:docsNeed to modify the documentation

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions