コード例 #1
0
def loss_weights(N):
    if FUNC_TYPE == 0:  # exponential spacing
        return anytime_loss.at_func(N, func=lambda x: 2**x)
    elif FUNC_TYPE == 1:  # square spacing
        return anytime_loss.at_func(N, func=lambda x: x**2)
    elif FUNC_TYPE == 2:  #optimal at ?
        return anytime_loss.optimal_at(N, OPTIMAL_AT)
    elif FUNC_TYPE == 3:  #exponential weights
        return anytime_loss.exponential_weights(N, base=EXP_BASE)
    elif FUNC_TYPE == 4:  #constant weights
        return anytime_loss.constant_weights(N)
    elif FUNC_TYPE == 5:  # sieve with stack
        return anytime_loss.stack_loss_weights(N, NUM_UNITS_PER_STACK)
    elif FUNC_TYPE == 6:  # linear
        return anytime_loss.linear(N, a=0.25, b=1.0)
    elif FUNC_TYPE == 7:  # half constant, half optimal at -1
        return anytime_loss.half_constant_half_optimal(N, -1)
    elif FUNC_TYPE == 8:  # quater constant, half optimal
        return anytime_loss.quater_constant_half_optimal(N)
    elif FUNC_TYPE == 9:
        return anytime_loss.stack_loss_weights(N, NUM_UNITS_PER_STACK,
                                               anytime_loss.eann_sieve)
    else:
        raise NameError('func type must be either 0: exponential or 1: square\
            or 2: optimal at --opt_at, or 3: exponential weight with base --base'
                        )
コード例 #2
0
def loss_weights(N):
    return anytime_loss.exponential_weights(N, base=EXP_BASE)