Skip to content
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

Add OneHot layer for generating one hot embedding for zero-based integer features #3846

Closed
wants to merge 1 commit into from

Conversation

nhanitvn
Copy link

No description provided.

@nhanitvn nhanitvn mentioned this pull request Sep 22, 2016
Copy link
Member

@fchollet fchollet left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is the justification for adding a new layer here? Shouldn't this be part of the data preprocessing?



class OneHot(Layer):
'''Turn positive integers (indexes) into dense dummy vectors of fixed size
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Dense dummy vectors?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, may be "one-hot" is a more appropriate term.

@nhanitvn
Copy link
Author

@fchollet Thanks for reviewing the PR. I wrote about the reason for a dedicated layer in #3680. Basically, we may want a flexibility in encoding categorical features during network construction.

@fchollet
Copy link
Member

fchollet commented Sep 22, 2016

Since this layer is stateless (no weights) it is preferable to use Lambda(K.one_hot) IMO.

@fchollet fchollet closed this Sep 22, 2016
@nhanitvn
Copy link
Author

Agree @fchollet. Thanks for your comments. At least it is a good experience writing a custom Keras layer, :).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants