Skip to content
DeepForgeby svx
All problems
MediumDeep Learningdl-254

gMLP Gating Unit

Problem

Apply the gMLP gating unit: split the channel dimension in half and multiply the first half element-wise by the second half.

The signature is gmlp_gating_unit(x). x must have even length; the output has half the length.

Hint

The multiplicative gate is what lets gMLP rival attention on some tasks.

Test cases

case 1
in: [[1,2,3,4]]
expected: [3,8]
case 2
in: [[0,1,2,3]]
expected: [0,3]
case 3
in: [[1,2]]
expected: [2]
case 4
in: [[-1,2,-3,4]]
expected: [3,8]
Starter codePython
def gmlp_gating_unit(x):
    # Your code here
    pass

4 test cases · run your code against them in the editor