KerasHub provides Keras implementations of pretrained models, their weights, and tools for preparing inputs. It is a separate package from Keras. In R, declare the Python dependency with `py_require("keras-hub")`, then load it with `import("keras_hub")`; if you manage your own Python environment, install it with `pip install keras-hub`. section 8.3.1
Start with a pretrained image backbone
`py_require("keras-hub")` `keras_hub <- import("keras_hub")` `conv_base <- keras_hub$models$Backbone$from_preset("xception_41_imagenet")` `from_preset()` retrieves the Xception configuration and weights. A backbone is the feature-extracting network without its classification head. For a dogs-versus-cats classifier, preprocess images with an `ImageConverter` from the same preset, extract features with the backbone, and train a new classifier on those features. Freeze the backbone when training a classifier on augmented images so its pretrained weights do not change. section 8.3.1
Presets also help keep language-model parts together. For RoBERTa, load both `Tokenizer` and `Backbone` with `from_preset("roberta_base_en")`. The tokenizer must map text to the token indices used during pretraining, and the backbone must match the architecture expected by the weights. section 15.4.2
Other practical uses include:
- Wrap SentencePiece as a Keras tokenizer layer to turn text into integer tokens and detokenize them again. The tokenizer can feed a `tf.data` pipeline for mini-GPT pretraining. section 16.2
- Load `CausalLM` from the `gemma3_1b` preset to get a pretrained Gemma model with a matching tokenizer. Compile a sampling strategy and call `generate()` to continue a prompt. Accessing these weights requires accepting the Gemma terms and authenticating with Kaggle; plausible output is not necessarily useful or accurate. section 16.3.1

