-
Notifications
You must be signed in to change notification settings - Fork 19.4k
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
OneHot Layer #3680
Comments
Lambda(K.one_hot()) instead as suggested by @fchollet |
There are a few catches when using Lambda(K.one_hot), but generally it's possible:
Try this like:
|
Full example in a gist: https://gist.github.com/bzamecnik/a33052ec46ee7efeb217856d98a4fb5f |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
From my current modeling tasks, I see that it would be useful to have the flexibility to encode a categorical feature either in one-hot format or embedding format (using Embedding layer) right in the model construction phase instead of creating dummy columns in advance in case of one-hot encoding (it is the zero-based integers in case of Embedding). Though we can use Lambda layer for that purpose, I think it would be more convenient to have a OneHot layer instead. I wrote the code for the propose OneHot layer already which just calls
K.one_hot()
internally. Feel free to give your thought on whether we should add such layer or not in Keras. I am happy to contribute the code via a PR. Thanks.The pseudo-code would be like this
I created a PR #3846
The text was updated successfully, but these errors were encountered: