def LNKS_fobj(theta, stim, y, options): ''' LNKS model objective function for using only firing rate as output Returns objective value(J) and gradient(grad) Inputs ------ theta: model parameters stim: input data y: output data (fr) options (dictionary): pathway: LNK pathway (1 or 2) is_grad: bool (gradient on or off) Outputs ------- J: objective value grad: gradient of objective ''' J = LNKS_fobj_helper(LNKS_f, theta, stim, y, options) if options['is_grad']: grad = _obj.fobj_numel_grad(LNKS_fobj_helper, LNKS_f, theta, stim, y, options) return J, grad else: return J
def LNKS_MP_fobj(theta, stim, y_data, options): ''' LNKS model objective function for using both membrane potential and firing rate Returns objective value(J) and gradient(grad) Inputs ------ theta: model parameters stim: input data y_data: output data tuple (mp, fr) options (dictionary): pathway: LNK pathway (1 or 2) is_grad: bool (gradient on or off) Outputs ------- J: objective value grad: gradient of objective ''' J = LNKS_MP_fobj_helper(LNKS_MP_f, theta, stim, y_data, options) if options['is_grad']: grad = _obj.fobj_numel_grad(LNKS_MP_fobj_helper, LNKS_MP_f, theta, stim, y_data, options) return J, grad else: return J