Documentation

Hesper.NN.Activation

Neural Network Activation Functions #

GPU kernels for common activation functions using the ShaderM monad. All operations are element-wise on tensors.

Configuration for activation function kernels

  • size : Nat

    Number of elements to process

  • workgroupSize : Nat

    Workgroup size (threads per workgroup)

Instances For
    Equations
    • One or more equations did not get rendered due to their size.
    Instances For

      Number of workgroups needed

      Equations
      Instances For

        ReLU activation kernel: f(x) = max(0, x)

        Equations
        • One or more equations did not get rendered due to their size.
        Instances For

          Leaky ReLU kernel: f(x) = max(alpha * x, x)

          Equations
          • One or more equations did not get rendered due to their size.
          Instances For

            GELU activation kernel (approximate)

            Equations
            • One or more equations did not get rendered due to their size.
            Instances For

              Sigmoid activation kernel: f(x) = 1 / (1 + exp(-x))

              Equations
              • One or more equations did not get rendered due to their size.
              Instances For

                Tanh activation kernel: f(x) = tanh(x)

                Equations
                • One or more equations did not get rendered due to their size.
                Instances For

                  Swish/SiLU activation kernel: f(x) = x * sigmoid(x)

                  Equations
                  • One or more equations did not get rendered due to their size.
                  Instances For

                    ELU activation kernel: f(x) = x if x > 0 else alpha * (exp(x) - 1)

                    Equations
                    • One or more equations did not get rendered due to their size.
                    Instances For

                      Softplus activation kernel: f(x) = log(1 + exp(x))

                      Equations
                      • One or more equations did not get rendered due to their size.
                      Instances For

                        Mish activation kernel: f(x) = x * tanh(softplus(x))

                        Equations
                        • One or more equations did not get rendered due to their size.
                        Instances For

                          Softmax activation kernel (simplified version for demo) Note: This is a simplified implementation. Production softmax requires multi-pass reduction for finding max and sum across the entire array.

                          Equations
                          • One or more equations did not get rendered due to their size.
                          Instances For

                            Generate WGSL shader for Leaky ReLU

                            Equations
                            Instances For

                              Generate WGSL shader for ELU

                              Equations
                              Instances For

                                Generate WGSL shader for Softmax (simplified version)

                                Equations
                                Instances For