Ejemplo n.º 1
0
def LNKS_fobj_helper(f, theta, stim, y, options):
    '''
    LNKS model objective function helper function

    Weighted sum of log-likelihood and mean-square error
    '''

    model = options['model']

    if model == 'LNK':
        y_est = f(theta, stim, options)
        J = _obj.mse_weighted_loss(y, y_est, len_section=10000, weight_type='std')

    elif model == 'LNKS':
        y_est = f(theta, stim, options)
        # linear combination of objective functions
        J_mse = _obj.mse_weighted_loss(y, y_est, len_section=10000, weight_type='mean')
        J_poss = _obj.poisson_weighted_loss(y, y_est, len_section=10000, weight_type="mean")
        J = J_poss + J_mse

    elif model == 'LNKS_MP':
        # data
        y_mp = y[0]
        y_fr = y[1]
        y_mp_est, y_fr_est = f(theta, stim, options)
        # linear combination of objective functions
        J_mp = _obj.mse_weighted_loss(y_mp, y_mp_est, len_section=10000, weight_type="std")
        J_fr_poss = _obj.poisson_weighted_loss(y_fr, y_fr_est, len_section=10000, weight_type="mean")
        J_fr_mse = _obj.mse_weighted_loss(y_fr, y_fr_est, len_section=10000, weight_type="mean")
        J_fr = J_fr_poss + J_fr_mse
        J = J_mp + J_fr

    return J
Ejemplo n.º 2
0
def LNKS_MP_fobj_helper(f, theta, stim, y_data, options):
    '''
    LNKS model objective helper function for using both membrane potential and firing rate
    returns objective function value J

    Inputs
    -------
        f: LNKS model
        theta: model parameters
        stim: input data
        y_data: output data tuple (mp, fr)
        pathway (int): LNK pathway (1 or 2)

    Outputs
    -------
        J: objective value
    '''
    # data
    y_mp = y_data[0]
    y_fr = y_data[1]

    # model output
    y_mp_est, y_fr_est = f(theta, stim, options['pathway'])

    # linear combination of objective functions
    J_mp = _obj.mse_weighted_loss(y_mp, y_mp_est, len_section=10000, weight_type="std")
    J_fr_poss = _obj.poisson_weighted_loss(y_fr, y_fr_est, len_section=10000, weight_type="mean")
    J_fr_mse = _obj.mse_weighted_loss(y_fr, y_fr_est, len_section=10000, weight_type="mean")
    J_fr = J_fr_poss + J_fr_mse

    J = J_mp + J_fr

    return J
Ejemplo n.º 3
0
def LNKS_fobj_helper(f, theta, stim, y, options):
    '''
    LNKS model objective function helper function

    Weighted sum of log-likelihood and mean-square error
    '''

    y_est = f(theta, stim, options['pathway'])

    # linear combination of objective functions
    J_poss = _obj.poisson_weighted_loss(y, y_est, len_section=10000, weight_type="mean")
    J_mse = _obj.mse_weighted_loss(y, y_est, len_section=10000, weight_type="mean")
    J = J_poss + J_mse

    return J