Views
No views yet
pip install -U -q keras-hub
pip install -U -q keras| Preset Name | Parameters | Description |
|---|---|---|
deberta_v3_extra_small_en | 70.68M | 12-layer DeBERTaV3 model where case is maintained. Trained on English Wikipedia, BookCorpus and OpenWebText. |
deberta_v3_small_en | 141.30M | 6-layer DeBERTaV3 model where case is maintained. Trained on English Wikipedia, BookCorpus and OpenWebText. |
deberta_v3_base_en | 183.83M | 12-layer DeBERTaV3 model where case is maintained. Trained on English Wikipedia, BookCorpus and OpenWebText. |
deberta_v3_large_en | 434.01M | 24-layer DeBERTaV3 model where case is maintained. Trained on English Wikipedia, BookCorpus and OpenWebText. |
deberta_v3_base_multi | 278.22M | 12-layer DeBERTaV3 model where case is maintained. Trained on the 2.5TB multilingual CC100 dataset. |
1features = ["The quick brown fox jumped.", "I forgot my homework."]
2labels = [0, 3]1import keras
2import keras_hub
3import numpy as np1features = ["The quick brown fox jumped.", "I forgot my homework."]
2labels = [0, 3]
3
4# Pretrained classifier.
5classifier = keras_hub.models.DebertaV3Classifier.from_preset(
6 "deberta_v3_base_multi",
7 num_classes=4,
8)
9classifier.fit(x=features, y=labels, batch_size=2)
10classifier.predict(x=features, batch_size=2)
11
12# Re-compile (e.g., with a new learning rate).
13classifier.compile(
14 loss=keras.losses.SparseCategoricalCrossentropy(from_logits=True),
15 optimizer=keras.optimizers.Adam(5e-5),
16 jit_compile=True,
17)
18# Access backbone programmatically (e.g., to change `trainable`).
19classifier.backbone.trainable = False
20# Fit again.
21classifier.fit(x=features, y=labels, batch_size=2)1features = {
2 "token_ids": np.ones(shape=(2, 12), dtype="int32"),
3 "padding_mask": np.array([[1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0]] * 2),
4}
5labels = [0, 3]
6
7# Pretrained classifier without preprocessing.
8classifier = keras_hub.models.DebertaV3Classifier.from_preset(
9 "deberta_v3_base_multi",
10 num_classes=4,
11 preprocessor=None,
12)
13classifier.fit(x=features, y=labels, batch_size=2)1import keras
2import keras_hub
3import numpy as np1features = ["The quick brown fox jumped.", "I forgot my homework."]
2labels = [0, 3]
3
4# Pretrained classifier.
5classifier = keras_hub.models.DebertaV3Classifier.from_preset(
6 "hf://keras/deberta_v3_base_multi",
7 num_classes=4,
8)
9classifier.fit(x=features, y=labels, batch_size=2)
10classifier.predict(x=features, batch_size=2)
11
12# Re-compile (e.g., with a new learning rate).
13classifier.compile(
14 loss=keras.losses.SparseCategoricalCrossentropy(from_logits=True),
15 optimizer=keras.optimizers.Adam(5e-5),
16 jit_compile=True,
17)
18# Access backbone programmatically (e.g., to change `trainable`).
19classifier.backbone.trainable = False
20# Fit again.
21classifier.fit(x=features, y=labels, batch_size=2)1features = {
2 "token_ids": np.ones(shape=(2, 12), dtype="int32"),
3 "padding_mask": np.array([[1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0]] * 2),
4}
5labels = [0, 3]
6
7# Pretrained classifier without preprocessing.
8classifier = keras_hub.models.DebertaV3Classifier.from_preset(
9 "hf://keras/deberta_v3_base_multi",
10 num_classes=4,
11 preprocessor=None,
12)
13classifier.fit(x=features, y=labels, batch_size=2)