| ggml_clamp | R Documentation |
Creates a graph node for clamping values to a range: clamp(x, min, max)
ggml_clamp(ctx, a, min_val, max_val)
ctx |
GGML context |
a |
Input tensor |
min_val |
Minimum value |
max_val |
Maximum value |
Tensor with values clamped to [min_val, max_val]
GGML_OP_CLAMP has no backward pass, and the node it builds is a view
of its input. A graph containing it therefore cannot be differentiated: the
backward pass aborts with "inplace operations are currently not
supported" rather than returning an error. This matters inside
ggml_layer_custom, whose gradients flow only through
operations that implement a backward pass.
For a trainable equivalent, express the clamp with operations that do:
min(x, hi) is x - ggml_relu(ctx, x - hi) and max(x, lo)
is lo + ggml_relu(ctx, x - lo).
ggml_relu for the differentiable formulation above.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.