Skip to content

Non adaptable FeatureSpace features #302

Open
@fbadine

Description

@fbadine

If you open a GitHub issue, here is our policy:

It must be a bug, a feature request, or a significant problem with the documentation (for small docs fixes please send a PR instead).
The form below must be filled out.

Here's why we have that policy:.

Keras developers respond to issues. We want to focus on work that benefits the whole community, e.g., fixing bugs and adding features. Support only helps individuals. GitHub also notifies thousands of people when issues are filed. We want them to see you communicating an interesting problem, rather than being redirected to Stack Overflow.

System information.

TensorFlow version (you are using): 2.12
Are you willing to contribute it (Yes/No) : Yes

Describe the feature and the current behavior/state.

In the FeatureSpace, there is no way to add a feature that is non adaptable.
I was interested in adding a float_discretized feature giving it the bin_boundaries. 2 issues were faced:

  • num_bins is mandatory which contradicts the keras.layers.Discretization layer where neither num_bins nor bin_boundaries are mandatory
  • The other issue is that when bin_boundaries is set, it fails on adapt which is normal because when bin_boundaries is set, the layer must not be adapted.

Even for the float_normalization, we cannot pass a "mean" field in order to set the Normalization layer input_mean value so that when _list_adaptable_preprocessors is called, it can be skipped and not adapted.

What I propose

Describe the feature clearly here. Be sure to convey here why the requested feature is needed. Any brief description about the use-case would help.

I propose the following:

  • For float_normalization, to add mean and variance so that we can add them and the layer won't be adapted then
  • For float_discretization, make num_bins not mandatory defaulting to None and adjust _list_adaptable_preprocessors to skip processors whose instance is layer.Discretization if bin_boundaries is not None

Will this change the current api? How?

It will give flexibility to users who wish to add features that do not need to be adapted

Who will benefit from this feature?

As stated earlier, users who want to add features without adapting

Contributing

  • Do you want to contribute a PR? (yes/no): yes
  • If yes, please read this page for instructions
  • Briefly describe your candidate solution(if contributing):

As described earlier, my solution consists of editing the following:

  • in FeatureSpace._list_adaptable_preprocessors, add another if to check if the preprocessor is layer.Discretization and has bin_boundaries not None. If so, continue without adding the feature to the list of features to be adapted.
  • In FeatureSpace.float_normalized, add mean and variance to be passed to layer.Normalization
  • In FeatureSoace.float_discretization, make num_boundaries = None in order to be able not to pass it.

Metadata

Metadata

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions