The LambdaCallback docstring states arguments are positional:

https://github.com/keras-team/keras/blob/22ab5a33484cf9a39e7a07f24ddfb2072f0da698/keras/src/callbacks/lambda_callback.py#L13-L18

but they are sometimes passed as keyword, e.g. at

https://github.com/keras-team/keras/blob/22ab5a33484cf9a39e7a07f24ddfb2072f0da698/keras/src/callbacks/callback_list.py#L150

which may cause issues in case someone (like me) tries implementing a lambda as lambda epoch, _: ... or lambda batch, _: ... in case we don't need logs to avoid linter warnings about unused variables.

Since changing the docs is easier than the API, I would suggest just changing the docstring to say "keyword" rather than "positional", or perhaps say that only logs may be passed as keyword since epoch and batch can be passed as positional?

Comment From: sonali-kumari1

Hi @tomaz-suller - Thanks for pointing this out. The docstring for LambdaCallback is correct for:

  • on_epoch_begin and on_epoch_end, which expect two positional arguments: epoch, logs
  • on_train_begin and on_train_end, which expect one positional argument:logs

However, for on_train_batch_begin and on_train_batch_end, batch is passed as a positional argument, whereas logs is passed as a keyword argument. We will look into this update you!