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

Updated Large-scale multi-label text classification example for Keras v3 #1779

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions examples/nlp/multi_label_classification.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,9 @@
## Imports
Copy link
Member

Choose a reason for hiding this comment

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

Can you update Last modified above and add yourself to the authors list?

"""

from tensorflow.keras import layers
from tensorflow import keras
import keras
from keras import layers

import tensorflow as tf

from sklearn.model_selection import train_test_split
Expand Down Expand Up @@ -145,7 +146,7 @@
"""

terms = tf.ragged.constant(train_df["terms"].values)
Copy link
Member

Choose a reason for hiding this comment

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

Would it work to use padding here instead of ragged tensors?
https://keras.io/api/ops/numpy/#pad-function

lookup = tf.keras.layers.StringLookup(output_mode="multi_hot")
lookup = layers.StringLookup(output_mode="multi_hot")
lookup.adapt(terms)
vocab = lookup.get_vocabulary()

Expand Down
Loading