Burn Core: burn::tensor::activation::prelu
The burn::tensor::activation::prelu function applies Parametric ReLU to an input tensor. The primary parameters are tensor, containing the input values, and alpha, containing the learnable or fixed negative-slope coefficients.
The operation is typically used in neural network layers where a fixed ReLU may be too restrictive. Positive values pass through directly, while negative values are scaled by the alpha parameter. In autodiff-enabled training, alpha may participate in gradient tracking when represented as a trainable parameter.
Parameters
| Parameter Name | Type | Description |
|---|---|---|
tensor |
Tensor<B, D> |
The input tensor to which Parametric ReLU is applied. |
alpha |
Tensor<B, D> | broadcast-compatible Tensor |
The negative-slope coefficient tensor used for values below zero. |
use burn::tensor::activation::prelu;
let x = Tensor::<B, 2>::ones([2, 4], &device);
let alpha = Tensor::<B, 1>::ones([4], &device);
let y = prelu(x, alpha);
Example Output
{
"status": "success",
"operation": "prelu",
"input_shape": [2, 4],
"alpha_shape": [4]
}