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

Update dtype argument for keras_core.Input #948

Closed SuryanarayanaY closed 9 months ago

SuryanarayanaY commented 9 months ago

At present,the API keras_core.input documentation states that the argument dtype to be passed as a string such as 'tf.float32' etc. However if we pass tf.dtypes.DType such as tf.float32,tf.float64 or a torch.dtype such as torch.float32,torch.float64 it will works as well as the internal code calls keras_core.backend.standardize_dtype which can convert tf.float32 or torch.float32 to string such as 'float32'.

IMO, its better to mention this is documentation that this API can also handle both tf.dtypes.DType and torch.dtype so that users are aware of this and they are free to choose any of the above ways to pass value to dtype.

Attached gist as reference for the above exercise.

codecov[bot] commented 9 months ago

Codecov Report

All modified lines are covered by tests :white_check_mark:

Comparison is base (3a464f9) 83.75% compared to head (567dbaa) 60.56%.

Additional details and impacted files ```diff @@ Coverage Diff @@ ## main #948 +/- ## =========================================== - Coverage 83.75% 60.56% -23.19% =========================================== Files 319 319 Lines 28879 28879 Branches 5529 5529 =========================================== - Hits 24189 17492 -6697 - Misses 3172 10044 +6872 + Partials 1518 1343 -175 ``` | [Flag](https://app.codecov.io/gh/keras-team/keras-core/pull/948/flags?src=pr&el=flags&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=keras-team) | Coverage Δ | | |---|---|---| | [keras_core](https://app.codecov.io/gh/keras-team/keras-core/pull/948/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=keras-team) | `60.56% <ø> (-23.09%)` | :arrow_down: | | [keras_core-jax](https://app.codecov.io/gh/keras-team/keras-core/pull/948/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=keras-team) | `?` | | | [keras_core-numpy](https://app.codecov.io/gh/keras-team/keras-core/pull/948/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=keras-team) | `60.56% <ø> (ø)` | | | [keras_core-tensorflow](https://app.codecov.io/gh/keras-team/keras-core/pull/948/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=keras-team) | `?` | | | [keras_core-torch](https://app.codecov.io/gh/keras-team/keras-core/pull/948/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=keras-team) | `?` | | Flags with carried forward coverage won't be shown. [Click here](https://docs.codecov.io/docs/carryforward-flags?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=keras-team#carryforward-flags-in-the-pull-request-comment) to find out more. | [Files](https://app.codecov.io/gh/keras-team/keras-core/pull/948?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=keras-team) | Coverage Δ | | |---|---|---| | [keras\_core/layers/core/input\_layer.py](https://app.codecov.io/gh/keras-team/keras-core/pull/948?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=keras-team#diff-a2VyYXNfY29yZS9sYXllcnMvY29yZS9pbnB1dF9sYXllci5weQ==) | `90.90% <ø> (ø)` | | ... and [176 files with indirect coverage changes](https://app.codecov.io/gh/keras-team/keras-core/pull/948/indirect-changes?src=pr&el=tree-more&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=keras-team)

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

SuryanarayanaY commented 9 months ago

APologies. PR created by mistake here as source code link points it to here.

Created a fresh PR in keras-team/keras with PR No. #18599 and hence closing here.

Thanks!