| ggml_freeze_weights | R Documentation |
Sets trainable = FALSE on layers, preventing their weights from being
updated during training. Layers are chosen by layer_names and/or
prefix; without either, by the index range from / to
(sequential models), or all of them.
ggml_freeze_weights(
model,
from = 1L,
to = length(model$layers),
layer_names = NULL,
prefix = NULL,
...
)
model |
A model object (ggml_sequential_model or ggml_functional_model) |
from |
Integer index of the first layer to freeze (default: 1) |
to |
Integer index of the last layer to freeze (default: last layer) |
layer_names |
Character vector of layer names to freeze (overrides from/to) |
prefix |
Character vector: freeze every layer whose name starts with one
of these – a whole transformer block, say: |
... |
Additional arguments passed to methods |
The model with selected layers frozen.
ggml_freeze_bn_stats to fix batch-norm statistics,
which freezing the weights does not do.
model <- ggml_model_sequential() |>
ggml_layer_dense(64, activation = "relu") |>
ggml_layer_dense(10, activation = "softmax")
# Freeze all layers
model <- ggml_freeze_weights(model)
# Freeze only the first layer
model <- ggml_freeze_weights(model, from = 1, to = 1)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.