nn_prelu {torch}R Documentation

PReLU module

Description

Applies the element-wise function:

\mboxPReLU(x)=max(0,x)+amin(0,x) \mbox{PReLU}(x) = \max(0,x) + a * \min(0,x)

or

\mboxPReLU(x)={x,\mboxifx0ax,\mboxotherwise \mbox{PReLU}(x) = \left\{ \begin{array}{ll} x, & \mbox{ if } x \geq 0 \\ ax, & \mbox{ otherwise } \end{array} \right.

Usage

nn_prelu(num_parameters = 1, init = 0.25)

Arguments

num_parameters

(int): number of aa to learn. Although it takes an int as input, there is only two values are legitimate: 1, or the number of channels at input. Default: 1

init

(float): the initial value of aa. Default: 0.25

Details

Here aa is a learnable parameter. When called without arguments, nn.prelu() uses a single parameter aa across all input channels. If called with nn_prelu(nChannels), a separate aa is used for each input channel.

Shape

Attributes

Note

weight decay should not be used when learning aa for good performance.

Channel dim is the 2nd dim of input. When input has dims < 2, then there is no channel dim and the number of channels = 1.

Examples

if (torch_is_installed()) {
m <- nn_prelu()
input <- torch_randn(2)
output <- m(input)
}

[Package torch version 0.13.0 Index]