ggml_layer_global_average_pooling_2d: Global Average Pooling for 2D Feature Maps

View source: R/nn_layers.R

ggml_layer_global_average_pooling_2dR Documentation

Global Average Pooling for 2D Feature Maps

Description

Reduces a [H, W, C] feature map to [C] by averaging all spatial positions per channel. Equivalent to Keras GlobalAveragePooling2D().

Usage

ggml_layer_global_average_pooling_2d(model, name = NULL, trainable = TRUE)

Arguments

model

A ggml_sequential_model or ggml_tensor_node.

name

Optional character name for the layer.

trainable

Logical; reserved for API consistency (no weights).

Value

Updated model or a new ggml_tensor_node.

Examples


model <- ggml_model_sequential() |>
  ggml_layer_conv_2d(32, c(3,3), activation = "relu",
                     input_shape = c(28, 28, 1)) |>
  ggml_layer_global_average_pooling_2d() |>
  ggml_layer_dense(10, activation = "softmax")


ggmlR documentation built on July 14, 2026, 1:08 a.m.