Ejemplo n.º 1
0
file_name = None
screen = False
if args.log.lower() in ['file', 'both']:
    file_name = 'neurokernel.log'
if args.log.lower() in ['screen', 'both']:
    screen = True
logger = base.setup_logger(file_name, screen)

if args.port_data is None and args.port_ctrl is None:
    port_data = get_random_port()
    port_ctrl = get_random_port()
else:
    port_data = args.port_data
    port_ctrl = args.port_ctrl

man = core.Manager(port_data, port_ctrl)
man.add_brok()

(n_dict, s_dict) = LPU_rev.lpu_parser('./data/antennallobe.gexf.gz')

al = LPU_rev(dt, n_dict, s_dict, input_file='./data/olfactory_input.h5',
             output_file='olfactory_output.h5', port_ctrl=port_ctrl,
             port_data=port_data,
             device=args.al_dev, id='al',
             debug=args.debug)
man.add_mod(al)

man.start(steps=args.steps)
man.stop()
Ejemplo n.º 2
0
else:
    port_data = args.port_data
    port_ctrl = args.port_ctrl

for i, neu_num in neu_dict.iteritems():
    lpu_entry = {}

    if i == 0:
        in_file_name = in_file_name_0
    else:
        in_file_name = None
    lpu_file_name = 'generic_lpu_%s.gexf.gz' % i
    out_file_name = 'generic_output_%s.h5' % i
    
    g.create_lpu(lpu_file_name, *neu_num)
    (n_dict, s_dict) = LPU_rev.lpu_parser(lpu_file_name)

    id = 'lpu_%s' % i
    lpu = LPU_rev(dt, n_dict, s_dict, input_file=in_file_name,
                  output_file=out_file_name,
                  port_ctrl=port_ctrl, port_data=port_data,
                  device=i, id=id,
                  debug=args.debug)
        
    lpu_entry['lpu_file_name'] = lpu_file_name
    lpu_entry['in_file_name'] = in_file_name
    lpu_entry['out_file_name'] = out_file_name
    lpu_entry['lpu'] = lpu
    lpu_entry['id'] = id

    lpu_dict[i] = lpu_entry
Ejemplo n.º 3
0
    steps= int(args.steps)
else:
    steps=10000

dt = 1e-4
dur = 1.0
Nt = 10000#int(dur/dt)

logger = base.setup_logger()

man = core.Manager(port_data=data_port, port_ctrl=ctrl_port)
man.add_brok()

(n_dict_lam, s_dict_lam) = lpu_parser('./config_files/lamina.gexf')

(n_dict, s_dict) = LPU_rev.lpu_parser( './config_files/lamina.gexf')



lam_org = LPU( dt, n_dict_lam, s_dict_lam,
        #input_file='videos/flicker_stripe_same6.h5',
                    output_file='lamina_output_org.h5', port_ctrl= man.port_ctrl,
                    port_data=man.port_data, device=dev1, id='lamina',
                    debug=args.debug)

lam = LPU_rev( dt, n_dict, s_dict,\
        #input_file='videos/flciker_stripe_same6.h5',
                    output_file='lamina_output.h5', port_ctrl=man.port_ctrl,
                    port_data=man.port_data, device=dev1, id='lamina',
                    debug=args.debug)
Ejemplo n.º 4
0
file_name = None
screen = False
if args.log.lower() in ['file', 'both']:
    file_name = 'neurokernel.log'
if args.log.lower() in ['screen', 'both']:
    screen = True
logger = base.setup_logger(file_name, screen)

if args.port_data is None and args.port_ctrl is None:
    port_data = get_random_port()
    port_ctrl = get_random_port()
else:
    port_data = args.port_data
    port_ctrl = args.port_ctrl

man = core.Manager(port_data, port_ctrl)
man.add_brok()

(n_dict, s_dict) = LPU_rev.lpu_parser('./data/generic_lpu.gexf.gz')

ge = LPU_rev(dt, n_dict, s_dict,
             input_file='./data/generic_input.h5',
             output_file='generic_output.h5', port_ctrl=port_ctrl,
             port_data=port_data,
             device=args.gpu_dev, id='ge',
             debug=args.debug)
man.add_mod(ge)

man.start(steps=args.steps)
man.stop()
Ejemplo n.º 5
0
def run(connected):
    if args.port_data is None and args.port_ctrl is None:
        port_data = get_random_port()
        port_ctrl = get_random_port()
    else:
        port_data = args.port_data
        port_ctrl = args.port_ctrl

    out_name = 'un' if not connected else 'co'
    man = core.Manager(port_data, port_ctrl)
    man.add_brok()

    lpu_file_0 = './data/generic_lpu_0.gexf.gz'
    lpu_file_1 = './data/generic_lpu_1.gexf.gz'
    (n_dict_0, s_dict_0) = LPU_rev.lpu_parser(lpu_file_0)
    (n_dict_1, s_dict_1) = LPU_rev.lpu_parser(lpu_file_1)

    ge_0_id = 'ge_0'
    ge_0 = LPU_rev(dt, n_dict_0, s_dict_0,
                   input_file='./data/generic_input_0.h5',
                   output_file='generic_output_0_%s.h5' % out_name,
                   port_ctrl=port_ctrl, port_data=port_data,
                   device=args.gpu_dev[0], id=ge_0_id,
                   debug=args.debug)
    man.add_mod(ge_0)

    ge_1_id = 'ge_1'
    ge_1 = LPU_rev(dt, n_dict_1, s_dict_1,
                   input_file='./data/generic_input_1.h5',
                   output_file='generic_output_1_%s.h5' % out_name,
                   port_ctrl=port_ctrl, port_data=port_data,
                   device=args.gpu_dev[1], id=ge_1_id,
                   debug=args.debug)
    man.add_mod(ge_1)

    # Connect the public neurons in the two LPUs:
    df_neu_0, df_syn_0 = neurokernel.tools.graph.graph_to_df(nx.read_gexf(lpu_file_0))
    df_neu_1, df_syn_1 = neurokernel.tools.graph.graph_to_df(nx.read_gexf(lpu_file_1))

    # Number of public neurons in each LPU:
    N_spike_0 = len(df_neu_0[(df_neu_0['spiking']==True)&(df_neu_0['public']==True)])
    N_gpot_0 = len(df_neu_0[(df_neu_0['spiking']==False)&(df_neu_0['public']==True)])

    N_spike_1 = len(df_neu_1[(df_neu_1['spiking']==True)&(df_neu_1['public']==True)])
    N_gpot_1 = len(df_neu_1[(df_neu_1['spiking']==False)&(df_neu_1['public']==True)])

    # Alpha function synaptic parameters:
    alphasynapse_type_params = {'AlphaSynapse': ['ad', 'ar', 'gmax', 'id', 'class', 'conductance',
                                                 'reverse']}

    if connected:
        conn = core.Connectivity(N_gpot_0, N_spike_0, N_gpot_1, N_spike_1, 1,
                                 ge_0.id, ge_1.id, alphasynapse_type_params)
        for id, (i, j) in enumerate(itertools.product(xrange(N_spike_0), xrange(N_spike_1))):
            conn[ge_0_id, 'spike', i, ge_1_id, 'spike', j] = 1
            conn[ge_0_id, 'spike', i, ge_1_id, 'spike', j, 0, 'name'] = 'int_0to1_%s_%s' % (i, j)
            conn[ge_0_id, 'spike', i, ge_1_id, 'spike', j, 0, 'model'] = 'AlphaSynapse'

            conn[ge_0_id, 'spike', i, ge_1_id, 'spike', j, 0, 'ad'] = 0.19*1000
            conn[ge_0_id, 'spike', i, ge_1_id, 'spike', j, 0, 'ar'] = 1.1*100
            conn[ge_0_id, 'spike', i, ge_1_id, 'spike', j, 0, 'class'] = 0
            conn[ge_0_id, 'spike', i, ge_1_id, 'spike', j, 0, 'conductance'] = True
            conn[ge_0_id, 'spike', i, ge_1_id, 'spike', j, 0, 'gmax'] = 0.003
            conn[ge_0_id, 'spike', i, ge_1_id, 'spike', j, 0, 'id'] = id
            conn[ge_0_id, 'spike', i, ge_1_id, 'spike', j, 0, 'reverse'] = 0.065

        man.connect(ge_0, ge_1, conn)

    man.start(steps=args.steps)
    man.stop()