Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
Synopsis
- threshold :: forall threshold value gradient layout device dataType shape m. (Scalar threshold, Scalar value, MonadThrow m) => threshold -> value -> Tensor gradient layout device dataType shape -> m (Tensor gradient layout device dataType shape)
- relu :: forall gradient layout device dataType shape. Tensor gradient layout device dataType shape -> Tensor gradient layout device dataType shape
- gelu :: forall gradient layout device dataType shape. Tensor gradient layout device dataType shape -> Tensor gradient layout device dataType shape
- geluNew :: forall gradient layout device dataType shape m. MonadThrow m => Tensor gradient layout device dataType shape -> m (Tensor gradient layout device dataType shape)
- hardtanh :: forall minValue maxValue gradient layout device dataType shape m. (Scalar minValue, Scalar maxValue, MonadThrow m) => minValue -> maxValue -> Tensor gradient layout device dataType shape -> m (Tensor gradient layout device dataType shape)
- hardswish :: forall gradient layout device dataType shape. Tensor gradient layout device dataType shape -> Tensor gradient layout device dataType shape
- elu :: forall alpha gradient layout device dataType shape m. (Scalar alpha, MonadThrow m) => alpha -> Tensor gradient layout device dataType shape -> m (Tensor gradient layout device dataType shape)
- selu :: forall gradient layout device dataType shape m. MonadThrow m => Tensor gradient layout device dataType shape -> m (Tensor gradient layout device dataType shape)
- celu :: forall alpha gradient layout device dataType shape m. (Scalar alpha, MonadThrow m) => alpha -> Tensor gradient layout device dataType shape -> m (Tensor gradient layout device dataType shape)
- leakyRelu :: forall negativeSlope gradient layout device dataType shape m. (Scalar negativeSlope, MonadThrow m) => negativeSlope -> Tensor gradient layout device dataType shape -> m (Tensor gradient layout device dataType shape)
- prelu :: forall gradient' gradient layout device dataType shape m. MonadThrow m => Tensor gradient' layout device dataType shape -> Tensor gradient layout device dataType shape -> m (Tensor gradient layout device dataType shape)
Documentation
>>>
import Torch.GraduallyTyped.Prelude.List (SList (..))
>>>
import Torch.GraduallyTyped
:: forall threshold value gradient layout device dataType shape m. (Scalar threshold, Scalar value, MonadThrow m) | |
=> threshold | threshold |
-> value | value |
-> Tensor gradient layout device dataType shape | input |
-> m (Tensor gradient layout device dataType shape) | output |
Thresholds each element of the input Tensor.
:: forall gradient layout device dataType shape. Tensor gradient layout device dataType shape | input |
-> Tensor gradient layout device dataType shape | output |
Applies the rectified linear unit function element-wise, that is, \[ \text{ReLU}(x) = max(0, x). \]
:: forall gradient layout device dataType shape. Tensor gradient layout device dataType shape | input |
-> Tensor gradient layout device dataType shape | output |
Applies the gaussian error linear unit function element-wise.
:: forall gradient layout device dataType shape m. MonadThrow m | |
=> Tensor gradient layout device dataType shape | input |
-> m (Tensor gradient layout device dataType shape) | output |
Applies the gaussian error linear unit function element-wise.
This is the implementation of the GELU activation function from Google's BERT repo (and coincidentally also from OpenAI's GPT). See also https://arxiv.org/abs/1606.08415.
>>>
t <- sFull (TensorSpec (SGradient SWithGradient) (SLayout SDense) (SDevice SCPU) (SDataType SFloat) (SShape $ SNil)) 0.5
>>>
t' <- geluNew t
>>>
fromTensor @Float t'
0.345714
:: forall minValue maxValue gradient layout device dataType shape m. (Scalar minValue, Scalar maxValue, MonadThrow m) | |
=> minValue | minimum value |
-> maxValue | maximum value |
-> Tensor gradient layout device dataType shape | input |
-> m (Tensor gradient layout device dataType shape) | output |
Applies the HardTanh function element-wise.
:: forall gradient layout device dataType shape. Tensor gradient layout device dataType shape | input |
-> Tensor gradient layout device dataType shape | output |
Applies the hardswish function element-wise.
:: forall alpha gradient layout device dataType shape m. (Scalar alpha, MonadThrow m) | |
=> alpha | alpha value for ELU formulation |
-> Tensor gradient layout device dataType shape | input |
-> m (Tensor gradient layout device dataType shape) | output |
Applies the exponential linear unit function element-wise, with alpha input, \[ \text{ELU}(x) = \max(0,x) + \min(0, \alpha * (\exp(x) - 1)). \]
:: forall gradient layout device dataType shape m. MonadThrow m | |
=> Tensor gradient layout device dataType shape | input |
-> m (Tensor gradient layout device dataType shape) | output |
Applies the scaled exponential linear unit function element-wise, that is, \[ \text{SELU}(x) = \text{scale} * (\max(0,x) + \min(0, \alpha * (\exp(x) - 1)), \] with \(\alpha = 1.6732632423543772848170429916717\) and \(\text{scale}=1.0507009873554804934193349852946\).
:: forall alpha gradient layout device dataType shape m. (Scalar alpha, MonadThrow m) | |
=> alpha | alpha |
-> Tensor gradient layout device dataType shape | input |
-> m (Tensor gradient layout device dataType shape) | output |
Applies the continuously differentiable exponential linear unit function element-wise, that is, \[ \text{CELU}(x) = \max(0,x) + \min(0, \alpha * (\exp(x/\alpha) - 1)). \]
:: forall negativeSlope gradient layout device dataType shape m. (Scalar negativeSlope, MonadThrow m) | |
=> negativeSlope | negative slope |
-> Tensor gradient layout device dataType shape | input |
-> m (Tensor gradient layout device dataType shape) | output |
Applies the element-wise function: \[ \text{LeakyReLU}(x) = \max(0,x) + \text{negativeSlope} * \min(0,x), \] the the angle of the negative slope can be controlled. A typical value for it is 0.01.
:: forall gradient' gradient layout device dataType shape m. MonadThrow m | |
=> Tensor gradient' layout device dataType shape | weight (typically learnable) |
-> Tensor gradient layout device dataType shape | input |
-> m (Tensor gradient layout device dataType shape) | output |
Applies the parameterized rectified linear unit function element-wise, that is, \[ \text{PReLU}(x) = max(0, x) + \text{weight} * min(0, x). \] The weight parameter is typically learnable.