def EMLPBlock(rep_in, rep_out): """ Basic building block of EMLP consisting of G-Linear, biLinear, and gated nonlinearity. """ linear = Linear(rep_in, gated(rep_out)) bilinear = BiLinear(gated(rep_out), gated(rep_out)) nonlinearity = GatedNonlinearity(rep_out) return _EMLPBlock(linear, bilinear, nonlinearity)
def EMLPBlock(repin, repout): """ Basic building block of EMLP consisting of G-Linear, biLinear, and gated nonlinearity. """ linear = Linear(repin, gated(repout)) bilinear = BiLinear(gated(repout), gated(repout)) nonlinearity = GatedNonlinearity(repout) def block(x): lin = linear(x) preact = bilinear(lin) + lin return nonlinearity(preact) return block
def __init__(self, rep_in, rep_out): super().__init__() self.linear = Linear(rep_in, gated(rep_out)) self.bilinear = BiLinear(gated(rep_out), gated(rep_out)) self.nonlinearity = GatedNonlinearity(rep_out)