| ggml_pool_1d | R Documentation |
Applies 1D pooling operation for downsampling.
ggml_pool_1d(ctx, a, op, k0, s0 = k0, p0 = 0L)
GGML_OP_POOL_MAX
GGML_OP_POOL_AVG
ctx |
GGML context |
a |
Input tensor |
op |
Pool operation constant (see details) |
k0 |
Kernel size (window size) |
s0 |
Stride (default = k0 for non-overlapping windows) |
p0 |
Padding (default 0) |
An object of class integer of length 1.
An object of class integer of length 1.
Pool operation constants:
GGML_OP_POOL_MAX (0): Max pooling - takes maximum value in each window
GGML_OP_POOL_AVG (1): Average pooling - takes mean of values in each window
Pooled tensor with reduced dimensions
ctx <- ggml_init(16 * 1024 * 1024)
a <- ggml_new_tensor_1d(ctx, GGML_TYPE_F32, 8)
ggml_set_f32(a, c(1, 3, 2, 4, 5, 2, 8, 1))
# Max pooling with kernel 2, stride 2
max_pool <- ggml_pool_1d(ctx, a, GGML_OP_POOL_MAX, k0 = 2)
# Result: [3, 4, 5, 8] (max of each pair)
# Average pooling with kernel 2, stride 2
avg_pool <- ggml_pool_1d(ctx, a, GGML_OP_POOL_AVG, k0 = 2)
# Result: [2, 3, 3.5, 4.5] (mean of each pair)
ggml_free(ctx)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.