| new_act_fn | R Documentation |
Wraps a user-supplied function into a validated custom activation,
ensuring it accepts and returns a torch_tensor. Performs an eager
dry-run probe at definition time so errors surface early, and
wraps the function with a call-time type guard for safety.
new_act_fn(fn, probe = TRUE, .name = "<custom>")
fn |
A function taking a single tensor argument and returning a tensor.
E.g. |
probe |
Logical. If |
.name |
A string to be stored in an attribute. Nothing special, except it is
used when displaying the info of a trained neural network model.
Default is |
An object of class c("custom_activation", "parameterized_activation"),
compatible with act_funs().
## Not run:
\donttest{
act_funs(relu, elu, new_act_fn(\(x) torch::torch_tanh(x)))
act_funs(new_act_fn(\(x) torch::nnf_silu(x)))
}
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.