Beispiel #1
0
def reduce_model(modin):

    rsm = reduce_model_list(modin, [
        Dropout, nn.ReLU, nn.Softmax, PositionalEmb, TokenDropout, Sparsemax,
        CoordinateEmb, Swish
    ], [
        lambda m: (
            m.p,
            m.inplace,
        ), lambda m: (m.inplace, ), lambda m: (m.dim, ), lambda m: (
            m.num_pos,
            m.num_dim,
            m.poff,
            m.doff,
            m.alpha,
        ), lambda m: (
            m.p,
            m.keep_magnitude,
        ), lambda m: (m.dim, ), lambda m: (
            m.num_pos,
            m.num_dim,
            m.poff,
            m.doff,
            m.alpha,
            m.num_steps,
        ), lambda m: (
            m.reset_beta,
            m.beta,
        )
    ])
    return reduce_model_list(rsm, [GeLU_GPT, GeLU_BERT, nn.Tanh, nn.Sigmoid])
Beispiel #2
0
def reduce_model(modin):

    rsm = reduce_model_list(modin, [nn.ReLU, nn.Softmax, Sparsemax, Swish], [
        lambda m: (m.inplace, ), lambda m: (m.dim, ), lambda m:
        (m.dim, ), lambda m: (m.reset_beta, m.beta, m.dim, m.eps)
    ])

    return reduce_model_list(
        rsm, [GELU, GeLU_GPT, GeLU_BERT, Mish, nn.Tanh, nn.Sigmoid])
Beispiel #3
0
def reduce_model(modin):

    return reduce_model_list(modin, [Dropout, TokenDropout, NGramDropout], [
        lambda m: (
            m.p,
            m.inplace,
        ), lambda m: (
            m.p,
            m.inplace,
            m.keep_magnitude,
        ), lambda m: (
            m.p,
            m.inplace,
            m.seqdim,
            m.keep_magnitude,
            m.sample_p,
            m.max_n,
        )
    ])
Beispiel #4
0
def reduce_model(modin):

    rsm = reduce_model_list(modin, [PositionalEmb, CoordinateEmb], [
        lambda m: (
            m.num_pos,
            m.num_dim,
            m.poff,
            m.doff,
            m.alpha,
        ),
        lambda m: (
            m.num_pos,
            m.num_dim,
            m.poff,
            m.doff,
            m.alpha,
            m.num_steps,
        ),
    ])

    return reduce_model_drop(reduce_model_act(rsm))