New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
FeatureSpace multiple output from one input #19697
Comments
This does not appear to require any extra features:
You can do the above either inside the model or in a data pipeline. Inside the model would look like this: # Retrieve a dict Keras Input objects
inputs = feature_space.get_inputs()
# Retrieve the corresponding encoded Keras tensors
encoded_features = feature_space.get_encoded_features()
x = encoded_features["x"]
x_sqrt = keras.ops.sqrt(x)
x_square = keras.ops.square(x)
output = ...
model = Model(inputs, output) |
Thank you @fchollet for the quick answer. The method you mentioned is how I do it already today.
This could be extended to more advanced transformation with "multiple" output from one input.
In theses example the first layer do require adapt but using the log1p example it does not have to. Then when you call adapt to feature space, "behind the scene" it would look for preprocessing layer and apply it when the layer implement a preprocessing class.
and since it does check if adapt exist before executing it then in the case of log1p then this would work out of the box. |
Another more trivial example is for example if you want to transform one feature (eg.
So in this scenario from one input you created 2 preprocessing features where one is being used as a cross feature. |
This is more of an ask to add to a tutorial than a feature request as I believe this might already doable today.
When looking at the FeatureSpace tutorials it assumes that you create one output per feature.
I am basing this from this tutorial where it seems to be an assumption that from one input you create one output.
For example:
In this example there is an assumption that you only create one float_discretized output for the input age.
However, in practice (eg. youtube paper) multiple output can be created from one input.
It would be nice to add in the tutorial or somewhere in the doc an example to do so. I have tried to replicate the paper on numerical features using FeatureSpace and I found it difficult to do so without doing the extra transformation in the model itself which I think is not the initial idea of this functionality.
Please also note that not all preprocessing requires an adapt method in practice.
For example from Are Neural Rankers still Outperformed by Gradient Boosted Decision Trees?, they encourage to do this transformation -> x = log(1 + |x|) * sign(x).
In this case, you don't really need an adapt method to implement this. I think it would be beneficial to consider to open it to not only preprocessing class implementation but that is a different topic that I can open a different ticket if it is better to do so.
The text was updated successfully, but these errors were encountered: