keras-team / keras-core

A multi-backend implementation of the Keras API, with support for TensorFlow, JAX, and PyTorch.
Apache License 2.0
1.27k stars 115 forks source link

[*.py] Standardise docstring usage of "Default to" #921

Closed SamuelMarks closed 10 months ago

SamuelMarks commented 10 months ago

It's me again! - PS: I can split this into multiple PRs if you prefer.


I am trying to treat JAX, TensorFlow, PyTorch and Keras [amongst others] as data.

For example, translating the API hierarchy from Python to SQL; or generating type-safe help-text included CLIs. This will enable a number of new use-cases.

Unfortunately as it stands, your codebase lacks the type specificity for these use-cases. This is the first, probably of many, PRs to make your codebase consistent enough to be useful for these cases.

Additionally it'll generate better documentation for your primary use-cases; and make it clearer what types are being used where.

E.g., Defaults to 1. is ambiguous. Is 1 a float or an int?

Knowing the difference is then useful for continuous variable optimisation (e.g., Ray Tune or Google Vizier hyperparameter optimisation across the int or float domain). (as an aside; I am interesting in constraining the type numerical range more specifically also; like ASN.1 or Fortran allows)

SamuelMarks commented 10 months ago

@fchollet You're welcome.

As for a linter, I'd have to investigate the options and maybe extend them with defaults to linting:

Will see if I can send you a PR for it soon.

I think in the meantime having this consistency throughout the codebase gives new contributors a hint as to the expectation.