Learn R Programming

ggmlR (version 0.6.1)

ggml_layer_dense: Add Dense (Fully Connected) Layer

Description

Add Dense (Fully Connected) Layer

Usage

ggml_layer_dense(
  model,
  units,
  activation = NULL,
  input_shape = NULL,
  name = NULL,
  trainable = TRUE
)

Value

The model object with the dense layer appended (invisibly).

Arguments

model

A ggml_sequential_model object

units

Number of output units

activation

Activation function name: "relu", "sigmoid", "tanh", "softmax", or NULL

input_shape

Integer or integer vector specifying the input shape (only needed for the first layer)

name

Optional character name for the layer.

trainable

Logical; whether the layer weights are updated during training.

Examples

Run this code
# \donttest{
model <- ggml_model_sequential() |>
  ggml_layer_conv_2d(32, c(3,3), activation = "relu",
                     input_shape = c(28, 28, 1)) |>
  ggml_layer_flatten() |>
  ggml_layer_dense(128, activation = "relu")
# }

Run the code above in your browser using DataLab