| ggml_freeze_weights | R Documentation |
Sets trainable = FALSE on layers, preventing their weights from being
updated during training. Accepts optional from / to to freeze
a range of layers by index, or layer_names to freeze by name.
If none are provided, all layers are frozen.
ggml_freeze_weights(
model,
from = 1L,
to = length(model$layers),
layer_names = 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) |
... |
Additional arguments passed to methods |
The model with selected layers frozen.
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.