网页
综合
更新时间 2026-11-15 00:14:29
Backbone
自动蜘蛛
keras.io
正文约 1479 字
Base class for all Backbone models.
A Backbone is the basic architecture for a given NLP model. Unlike a keras_hub.models.Task, a Backbone is not tailored to any specific loss function and training setup. A Backbone generally outputs the last hidden states of an architecture before any output predictions.
A Backbone can be used in one of two ways:
All backbones include a from_preset() constructor which can be used to load a pre-trained config and weights.
Instantiate a keras_hub.models.Backbone from a model preset.
A preset is a directory of configs, weights and other file assets used to save and load a pre-trained model. The preset can be passed as a one of:
This constructor can be called in one of two ways. Either from the base class like keras_hub.models.Backbone.from_preset(), or from a model class like keras_hub.models.GemmaBackbone.from_preset(). If calling from the base class, the subclass of the returning object will be inferred from the config in the preset directory.
For any Backbone subclass, you can run cls.presets.keys() to list all built-in presets available on the class.
Guides and examples using from_preset
A keras.layers.Embedding instance for embedding token ids.
This layer embeds integer token ids to the hidden dim of the model.
Enable Lora on the backbone.
Calling this method will freeze all weights on the backbone, while enabling Lora on the query & value EinsumDense layers of the attention layers.
Save backbone to a preset directory.
本页为82搜索生成的网页快照,内容来自站内索引;演示数据的原文链接仅作示例。