SwiGLU activation function

Neural Units & Activations DS practice problem on Onlearn.

Difficulty: easy.

Topics: Understanding Implement SwiGLU activation function, SwiGLU, Sigmoid Gating, Element-wise Multiplication, Broadcasting, Numerical Precision, Deep Learning Foundations, Numerical Computing, Computational Mathematics, Software Engineering, Neural Architecture Design, Activation Functions, Tensor Operations, Vectorized Programming, Neural Unit Design, Floating Point Arithmetic.

Problem Implement a Python function that applies the SwiGLU activation function to a NumPy array. Assume the input array has already been passed through a linear projection and has shape (batch size, 2d). Round each output to four decimal places and return the result as a NumPy array of the shape (batch size, d).