コード例 #1
0
ファイル: main.py プロジェクト: kolia/subunits
def _test_LNP( rgc_type='off parasol' ):
    vardict   = LNP( **thetaM( **linear_reparameterization()))
    init_LNP  = LNP_model( init_sv1(rgc_type) )
    indices = extract( linear_stats( rgc_type, (5,0) ), ['sparse_index', 'subunit_index'] )
    indices['N_subunits'] = len(cones)
    unknown = extract(init_LNP,['sv1'])
    train_LNP = global_objective( unknown, extract(init_LNP,['u','V2']), 
                                  vardict, run=linear_stats( rgc_type, (5,0) ),
                                  indices=indices)
    train_LNP.with_callback(callback)
    train_LNP.description = 'LNP'
    sv1 = optimize.optimizer( train_LNP )( init_params=unknown, maxiter=5000, gtol=1e-7 )
    model = LNP_model( train_LNP.unflat( sv1 )['sv1'] )
    model['LL'] = global_objective( unknown, extract(init_LNP,['u','V2']), 
                             vardict, run=linear_stats( rgc_type, (-5,0)), 
                             indices=indices).LL(sv1)
    save(model,'LNP_'+rgc_type)
    return model
コード例 #2
0
ファイル: main.py プロジェクト: kolia/subunits
def callback( objective , params , force=False , other={} , objectives=[] , plot_every=42):
    result = objective.unflat(params)
#    ipdb.set_trace()
    result.update(other)
    for o in objectives:
        result.update( {o.description:o.LL(params)} )
    for name,value in result.items():
        if hasattr(value, '__call__'):
            result[name] = value(params)
    try:
        display_params( result )
    except:
        pass
    if force or numpy.remainder( iterations[0] , plot_every ) == plot_every-1:
        filename = objective.description+('iter%d'%iterations[0])
#        filename = objective.description+'_'+'_'.join(sorted(result.keys()))+'_'+ \
#                  rgc_type+'_lam'+str(int(100*lam))+'_'+str(int(maxiter))+'iters'
        save(result,filename)
        plot_params( result, filename )
    iterations[0] = iterations[0] + 1
コード例 #3
0
ファイル: main.py プロジェクト: kolia/subunits
def ARD( stats , lam=0.00 ):
    stats['D'], stats['Z'] = schur(stats['cov'])
    print 'Starting ARD of size ', stats['Z'].shape,' with lambda=',lam
    sys.stdout.flush()
    D,Z = stats['D']/2 , stats['Z']
    print 'Schur decomposition completed'
    sys.stdout.flush()
    DD  = numpy.diag(D)
    keep= DD>1e-10
    P    =  (Z[:,keep] * numpy.sqrt(DD[keep])).T
    dSTA = numpy.concatenate(
        [STA[:,numpy.newaxis]-stats['mean'][:,numpy.newaxis] 
         for STA in stats['STA']], axis=1)
    y    =  numpy.dot ( (Z[:,keep] * 1/numpy.sqrt(DD[keep])).T , dSTA ) / 2
    iW = 1e-1
    for i in range(1):
        print 'Irlsing'
        sys.stdout.flush()
        V, iW = IRLS.IRLS( y, P, x=0, disp_every=1, lam=lam, maxiter=2 , 
                           ftol=1e-5, nonzero=1e-1, iw=iW)
        save({'V':V,'iW':iW},'Localizing_lam%.0e'%lam)
    return V, iW
コード例 #4
0
ファイル: main.py プロジェクト: kolia/subunits
#    print
#    print
#    print
#    print rgctype
#    print
#    print
#    infile = 're2STD_Uc2_'+rgctype
#
#    indices = extract( linear_stats(rgctype,(5,0)), ['sparse_index', 'subunit_index'] )
#    indices['N_subunits'] = len(cones)
#    iterations[0] = 0
#    retrain = optimize_LQLEP(rgctype, filename=infile, indices=indices,
#             description='posV1_L2v1_smooth10_c_', maxiter=42*5+2, 
#             vardict = LQLEP_positiveV1( **LQLEP_wBarrier( **LQLEP(
#                                         **thetaM( **u2c_parameterization())))))

for i in range(41,214,42)+[214]:
    filename = ('posV1_L2v1_newmooth_c_off parasoliter%d'%i)
    rgctype = 'off parasol'
#    plot_thetaM( filename, rgctype )
    e = exact_normalized_LLs( filename, rgctype )
    save( e, filename+'_LL' )
    print
    print 'Calculating simulated_STAC for', filename
    s = simulated_STAC( filename, rgctype)


#for rgctype in types:
#    infile = 're2STD_usmooth_'
#    e = exact_LL( filename=infile, rgctype=rgctype )
#    save( e, infile+'_LL' )