from_preset() is a KerasHub constructor for restoring a pretrained component from a named preset. It supplies the configuration and weights, and for language models can also load tokenizer assets, avoiding a hand-matched recreation of the architecture. section 15.4.2 section 8.3.1
Load RoBERTa or Xception
import keras_hub tokenizer = keras_hub.models.Tokenizer.from_preset("roberta_base_en") backbone = keras_hub.models.Backbone.from_preset("roberta_base_en") conv_base = keras_hub.models.Backbone.from_preset( "xception_41_imagenet", trainable=False, ) Use the matching preprocessing preset for image models: ImageConverter.from_preset("xception_41_imagenet", image_size=(180, 180)). section 15.4.2 section 8.3.1
Practical rules:
- Choose a preset that identifies the pretrained checkpoint, such as roberta_base_en or xception_41_imagenet. section 15.4.2 section 8.3.1
- Pair the restored backbone with its tokenizer or input converter so new inputs match pretraining. section 15.4.2 section 8.3.1
- Set trainable=False when using the backbone for fixed feature extraction; otherwise connect it to a task-specific head for fine-tuning. section 8.3.1
Listing 15.20 Loading the RoBERTa pretrained model with KerasHub
import keras_hub tokenizer = keras_hub.models.Tokenizer.from_preset("roberta_base_en") backbone = keras_hub.models.Backbone.from_preset("roberta_base_en")
Inspect the compact KerasHub loading pattern for a tokenizer and RoBERTa backbone. section 15.4.2

