]     
k={'fan_in':10.0}
l1=[]
l2=[]
for rule in rules:
    k.update({'display':False,
              'rule':rule,
              'source':source.get_name(),
              'target':target.get_name(),
              'save':{'active':True,
                      'overwrite':False,
                     'path':path_conn+rule}})

    c1=Conn('n1_n2', **k)
    c1.set(surfs, display_print=False)
    
    l1.append(c1.n)
    c2=Conn('n1_n2', **k)
    c2.set(surfs, display_print=False)
  
    l2.append(c2.n)
    
    
data_to_disk.pickle_save( [l1, l2], 
                              path+'data'+str(comm.rank()), 
                              all_mpi=True)
    
   

'''
Created on Sep 26, 2014

@author: mikael
'''
import sys

from toolbox import data_to_disk
from scripts_inhibition.oscillation_common import run_simulation

path_in, path_out = sys.argv[1:]

from_disk, threads = data_to_disk.pickle_load(path_in)

v = run_simulation(from_disk=from_disk,
                   threads=threads,
                   type_of_run='mpi_supermicro')

data_to_disk.pickle_save(v, path_out)
from toolbox.data_to_disk import pickle_save, pickle_load
# import cPickle as pickle
import sys
from toolbox.my_population import sim_group

# Necessary for pickle se
# http://stefaanlippens.net/pickleproblem
from toolbox.signal_processing import phases_diff

from toolbox.parallelization import comm, Barrier
fileName, fileOut =sys.argv[1:]

with Barrier():
    if comm.rank()==0:   
        out=pickle_load(fileName, all_mpi=True) 
    else:
        out=None


out=comm.bcast(out, root=0)
sim_time, args, kwargs=out

g=sim_group(sim_time, *args, **kwargs)

ss=g.get_spike_signal()
mr=ss.mean_rate()
fr=ss.firing_rate(1)

pickle_save([mr, fr], fileOut)
Beispiel #4
0
    1.33692641, 1.58262265, -0.96811121, -0.90521693, -1.08615044, -0.92152889,
    -0.90518609, 1.22187159, -0.82864912, -1.09725701, -1.02487258,
    -0.88972156, -1.30599356, 1.44669415, -1.40872227, -1.66689036,
    -0.86417846, -1.45717557, -1.42184061, 1.2057351, -1.37030109
]

w2 = [
    -0.14646108, 0.29853209, -0.48699606, 0.72563934, -4.35525632, -2.5833957,
    -0.26333364, 0.29597868, -0.07168969, 0.72605889, 0.37470257, -3.09585801,
    0.07714355, 0.16567262, 0.28941257, -0.23791818, 0.87030166, -2.12844598,
    -0.27904861, -0.16235359, -0.17206946, 0.01263502, 0.65328176, -2.29407062,
    0.08020149, 0.04580238, 0.0276981, 0.09061999, 0.52884198, -3.52870062,
    -2.21803758, -0.22725714, -0.08807848, 0.07054163, 0.84956287, 0.78336896,
    -2.76950798, -0.17292823, -0.06858274, -0.01542119, -0.05774084,
    0.48955128, -2.99184825, -0.00477945, 0.34411109, -0.06818302, 0.1137351,
    0.54493619, -2.55247086, 0.09282807
]

path = os.getcwd() + '/conn-h1/'
fileName = path + names[0]
data_to_disk.pickle_save([max(0, w) for w in w1], fileName)

fileName = path + names[1]
data_to_disk.pickle_save([max(0, w) for w in w2], fileName)

fileName = path + names[2]
data_to_disk.pickle_save([-min(0, w) for w in w1], fileName)

fileName = path + names[3]
data_to_disk.pickle_save([-min(0, w) for w in w2], fileName)
import numpy
import random
from toolbox import data_to_disk
import os

n_states=10
n_actions=5

names=['CO_M1', 'CO_M2', 'FS_M1', 'FS_M2']


for name in names[0:2]:
    w=[]
    for i in range(n_states):
        for j in range(n_actions):
            w.append(random.random())
    
    w=numpy.array(w)+0.5
    fileName=os.getcwd()+'/conn-fake/'+ name

    data_to_disk.pickle_save(w, fileName)
    
for name in names[2:]:
    w=[]
    for i in range(n_states*n_actions):
        w.append(random.random())
    
    w=numpy.array(w)
    fileName=os.getcwd()+'/conn-fake/'+ name

    data_to_disk.pickle_save(w, fileName)
    -1.53639621, -1.94314305, -1.77851693, -2.51990398, 1.33692641,
    1.58262265, -0.96811121, -0.90521693, -1.08615044, -0.92152889,
    -0.90518609, 1.22187159, -0.82864912, -1.09725701, -1.02487258,
    -0.88972156, -1.30599356, 1.44669415, -1.40872227, -1.66689036,
    -0.86417846, -1.45717557, -1.42184061, 1.2057351, -1.37030109]

w2=[-0.14646108, 0.29853209, -0.48699606, 0.72563934, -4.35525632,
    -2.5833957, -0.26333364, 0.29597868, -0.07168969, 0.72605889,
    0.37470257, -3.09585801, 0.07714355, 0.16567262, 0.28941257,    
    -0.23791818, 0.87030166, -2.12844598, -0.27904861, -0.16235359,
    -0.17206946, 0.01263502, 0.65328176, -2.29407062, 0.08020149,
    0.04580238, 0.0276981, 0.09061999, 0.52884198, -3.52870062,
    -2.21803758, -0.22725714, -0.08807848, 0.07054163, 0.84956287,
    0.78336896, -2.76950798, -0.17292823, -0.06858274, -0.01542119,
    -0.05774084, 0.48955128, -2.99184825, -0.00477945, 0.34411109,
    -0.06818302, 0.1137351, 0.54493619, -2.55247086, 0.09282807]

path=os.getcwd()+'/conn-h1/'
fileName=path+ names[0]
data_to_disk.pickle_save([max(0,w) for w in w1], fileName)
    
fileName=path+ names[1]
data_to_disk.pickle_save([max(0,w) for w in w2], fileName)

fileName=path+ names[2]
data_to_disk.pickle_save([-min(0,w) for w in w1], fileName)
    
fileName=path+ names[3]
data_to_disk.pickle_save([-min(0,w) for w in w2], fileName)

w1=[-0.21141305, -0.88669887, -0.37831674, -1.28668442, 0.96031735,
    1.55438281, -0.81223855, -1.06037949, -0.98036263, -0.8451992,
    -1.20849159, 1.44100766, -1.8383503, -2.13427109, -2.08055677,
    -0.2493982, -0.78163844, 1.15930543, -0.81645895, -0.81017504,
    -0.62118121, -1.13844397, -0.72094381, 1.0831174, -1.18996138,
    -1.53639621, -1.94314305, -1.77851693, -2.51990398, 1.33692641,
    1.58262265, -0.96811121, -0.90521693, -1.08615044, -0.92152889,
    -0.90518609, 1.22187159, -0.82864912, -1.09725701, -1.02487258,
    -0.88972156, -1.30599356, 1.44669415, -1.40872227, -1.66689036,
    -0.86417846, -1.45717557, -1.42184061, 1.2057351, -1.37030109]

w2=[-0.14646108, 0.29853209, -0.48699606, 0.72563934, -4.35525632,
    -2.5833957, -0.26333364, 0.29597868, -0.07168969, 0.72605889,
    0.37470257, -3.09585801, 0.07714355, 0.16567262, 0.28941257,    
    -0.23791818, 0.87030166, -2.12844598, -0.27904861, -0.16235359,
    -0.17206946, 0.01263502, 0.65328176, -2.29407062, 0.08020149,
    0.04580238, 0.0276981, 0.09061999, 0.52884198, -3.52870062,
    -2.21803758, -0.22725714, -0.08807848, 0.07054163, 0.84956287,
    0.78336896, -2.76950798, -0.17292823, -0.06858274, -0.01542119,
    -0.05774084, 0.48955128, -2.99184825, -0.00477945, 0.34411109,
    -0.06818302, 0.1137351, 0.54493619, -2.55247086, 0.09282807]


fileName=os.getcwd()+'/conn-h0/'+ names[0]
data_to_disk.pickle_save(numpy.array(w1), fileName)
    
fileName=os.getcwd()+'/conn-h0/'+ names[1]
data_to_disk.pickle_save(numpy.array(w2), fileName)

Beispiel #8
0
    'all_set-all_set',
]
k = {'fan_in': 10.0}
l1 = []
l2 = []
for rule in rules:
    k.update({
        'display': False,
        'rule': rule,
        'source': source.get_name(),
        'target': target.get_name(),
        'save': {
            'active': True,
            'overwrite': False,
            'path': path_conn + rule
        }
    })

    c1 = Conn('n1_n2', **k)
    c1.set(surfs, display_print=False)

    l1.append(c1.n)
    c2 = Conn('n1_n2', **k)
    c2.set(surfs, display_print=False)

    l2.append(c2.n)

data_to_disk.pickle_save([l1, l2],
                         path + 'data' + str(comm.rank()),
                         all_mpi=True)

out=comm.bcast(out, root=0)
sim_time, args, kwargs=out
d={'sd':{'active':True,
           'params':{'to_memory':False, 
                     'to_file':True}}}

kwargs=misc.dict_update(kwargs, d)

mkdir(data_path+'nest/')
my_nest.ResetKernel(display=False, 
                    data_path=data_path+'nest/',
                    **{'threads_local': np_local})
import pprint
pp=pprint.pprint
d=my_nest.GetKernelStatus()
if comm.rank()==0:
    print comm.size()
    pp(d)
    import threading
    print threading.active_count()

# comm.obj.
my_nest.SetKernelStatus({'overwrite_files':True,})
g=sim_group(sim_time, *args, **kwargs)



pickle_save(g, fileOut)
Beispiel #10
0
'''
Created on Oct 18, 2014

@author: mikael
'''

import sys
from toolbox.data_to_disk import pickle_load, pickle_save

path_in,path_out, =sys.argv[1:]

net=pickle_load(path_in)
d=net.simulation_loop()
pickle_save(d, path_out)
Beispiel #11
0
'''
Created on Oct 18, 2014

@author: mikael
'''

import sys
from toolbox.data_to_disk import pickle_load, pickle_save

path_in, path_out, = sys.argv[1:]

net = pickle_load(path_in)
d = net.simulation_loop()
pickle_save(d, path_out)
import numpy #just to not get segmentation fault
import sys

from toolbox.data_to_disk import pickle_save, pickle_load, mkdir
from toolbox.parallelization import (comm, Barrier, map_parallel,
                                     mockup_fun, mockup_fun_large_return_2,
                                     mockup_fun_large_return_1)
from toolbox import misc
np_local=2

fileName, fileOut, data_path =sys.argv[1:]

with Barrier():
    if comm.rank()==0:   
        out, mockup=pickle_load(fileName, all_mpi=True) 
    else:
        out=None
        mockup=None


out=comm.bcast(out, root=0)
mockup=comm.bcast(mockup, root=0)

print comm.rank()

with misc.Stopwatch('mpi'):
    a=map_parallel(mockup, out, out, **{'local_num_threads':np_local})  

pickle_save(a, fileOut)
Beispiel #13
0
'''

from toolbox.data_to_disk import pickle_save, pickle_load
# import cPickle as pickle
import sys
from toolbox.my_population import sim_group

# Necessary for pickle se
# http://stefaanlippens.net/pickleproblem
from toolbox.signal_processing import phases_diff

from toolbox.parallelization import comm, Barrier
fileName, fileOut = sys.argv[1:]

with Barrier():
    if comm.rank() == 0:
        out = pickle_load(fileName, all_mpi=True)
    else:
        out = None

out = comm.bcast(out, root=0)
sim_time, args, kwargs = out

g = sim_group(sim_time, *args, **kwargs)

ss = g.get_spike_signal()
mr = ss.mean_rate()
fr = ss.firing_rate(1)

pickle_save([mr, fr], fileOut)
'''

import numpy  #just to not get segmentation fault
import sys

from toolbox.data_to_disk import pickle_save, pickle_load, mkdir
from toolbox.parallelization import (comm, Barrier, map_parallel, mockup_fun,
                                     mockup_fun_large_return_2,
                                     mockup_fun_large_return_1)
from toolbox import misc
np_local = 2

fileName, fileOut, data_path = sys.argv[1:]

with Barrier():
    if comm.rank() == 0:
        out, mockup = pickle_load(fileName, all_mpi=True)
    else:
        out = None
        mockup = None

out = comm.bcast(out, root=0)
mockup = comm.bcast(mockup, root=0)

print comm.rank()

with misc.Stopwatch('mpi'):
    a = map_parallel(mockup, out, out, **{'local_num_threads': np_local})

pickle_save(a, fileOut)
Beispiel #15
0
'''
import numpy
import random
from toolbox import data_to_disk
import os

n_states = 10
n_actions = 5

names = ['CO_M1', 'CO_M2', 'FS_M1', 'FS_M2']

for name in names[0:2]:
    w = []
    for i in range(n_states):
        for j in range(n_actions):
            w.append(random.random())

    w = numpy.array(w) + 0.5
    fileName = os.getcwd() + '/conn-fake/' + name

    data_to_disk.pickle_save(w, fileName)

for name in names[2:]:
    w = []
    for i in range(n_states * n_actions):
        w.append(random.random())

    w = numpy.array(w)
    fileName = os.getcwd() + '/conn-fake/' + name

    data_to_disk.pickle_save(w, fileName)

from toolbox.parallelization import comm, Barrier
fileName, fileOut, data_path =sys.argv[1:]

with Barrier():
    if comm.rank()==0:   
        out=pickle_load(fileName, all_mpi=True) 
    else:
        out=None


out=comm.bcast(out, root=0)
sim_time, args, kwargs=out
d={'sd':{'active':True,
           'params':{'to_memory':False, 
                     'to_file':True}}}

kwargs=misc.dict_update(kwargs, d)

mkdir(data_path+'nest/')
my_nest.ResetKernel(display=False, data_path=data_path+'nest/')
my_nest.SetKernelStatus({'overwrite_files':True})
g=sim_group(sim_time, *args, **kwargs)
ss=g.get_spike_signal()

mr=ss.mean_rate()
print comm.rank,mr

pickle_save(ss, fileOut)