Learn R Programming

ggmlR (version 0.6.1)

ggml_apply: Apply a Layer Object to a Tensor Node

Description

Applies a ggml_layer object (created with ggml_dense(), ggml_lstm(), etc.) to a ggml_tensor_node. Applying the same layer object to multiple tensor nodes produces shared weights -- the identity of the layer object (layer$layer_id) is used as the sharing key, not its name.

Usage

ggml_apply(tensor, layer)

Value

A new ggml_tensor_node.

Arguments

tensor

A ggml_tensor_node (e.g. from ggml_input()).

layer

A ggml_layer object.

Examples

Run this code
# \donttest{
encoder <- ggml_dense(64L, activation = "relu")
x1 <- ggml_input(shape = 32L)
x2 <- ggml_input(shape = 32L)
out1 <- x1 |> ggml_apply(encoder)
out2 <- x2 |> ggml_apply(encoder)  # shared weights
model <- ggml_model(inputs = list(x1, x2),
                    outputs = list(out1, out2))
# }

Run the code above in your browser using DataLab