-
Notifications
You must be signed in to change notification settings - Fork 74k
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
Feature Request: tf.multi_one_hot that is one-hot encoding multiple columns of a Tensor #16044
Comments
@squall-1002 thanks for volunteering! I will mark "contributions welcome". |
@squall-1002 If you are not working on it can I make a PR? |
@divyanshj16 Thanks, I just pushed it and created the PR, but feel free to comment ;) |
@squall-1002 Could you give some practical example of this method? |
@wileeam Of course: Recommender Systems ;) |
hi, @squall-1002 , in recommender system, anyway we need to do some data process to merge the ID features (such as maker IDs) into a list. Do you think the code below is working as you expected?
The output is
|
(API review) I just closed #16300, which contained an implementation. We believe this function is too specialized and too hard to understand and use effectively to be of general use. I'll close this feature request. Sorry about the delay in making this decision. |
Amazing function !!! Very useful for ML models ! However it seems like a part is missing cat_int_tensors vs cat_tensors |
For people who would like to use Modified version of the code made by @lenjoy :
Outputs is in this case:
@martinwicke, I don't particularly agree that the function is too specialized. Multi-label classification problems are quite common nowadays and |
I agree with this. The usage of multi-hot labels isn't limited to just recommender systems, but also multi-output networks and multi-task learning. |
Any updates on this issue? What's the current recommended way to achieve multi_hot encoding for a set of string labels in TF-2.4? |
@mhorlacher you can use the following TF2.x snippet (modified from above) to turn integers to multi-hot:
To use this, you have to cast your string labels to integers. I hope this can help you (or others) as a starting point. Edit:
|
Hi @Yannik1337 - sorry for the late response. Yes this was the option I was going for in the end. Thanks! |
Hi there,
I just wrote a function that creates multiple one-hot-encodings for a tensor and concatenates them. I was curious whether this might serve some others and contribute this feature.
I am happy for your feedback. Tell me if you think others might profit and I would enjoy to create a pull request ;)
The text was updated successfully, but these errors were encountered: