Exemple #1
0
def runSORN(c, src):
    # Initialize experiment (source and statictics)
    (source, stats_single, _) = experiment.start(src)

    # Initialize SORN network, has simulation() and step() function
    sorn = Sorn(c, source)

    # Create a StatsCollection and fill it with methods for all statistics
    # that should be tracked (and later plotted)
    stats = StatsCollection(sorn)
    stats.methods = stats_single
    sorn.stats = stats

    # Datalog is used to store all results and parameters
    #stats.dlog.set_handler('*',utils.StoreToH5,
    #                       utils.logfilename("result.h5"))
    #stats.dlog.append('c', utils.unbunchify(c))
    #stats.dlog.set_handler('*',utils.TextPrinter)

    # Final experimental preparations
    experiment.reset(sorn)

    # Start stats
    sorn.stats.start()
    sorn.stats.clear()

    # Run experiment once
    pickle_objects = experiment.run(sorn)

    # Save sources etc
    for key in pickle_objects:
        filename = os.path.join(c.logfilepath, "%s.pickle" % key)
        topickle = pickle_objects[key]
        pickle.dump(topickle, gzip.open(filename, "wb"),
                    pickle.HIGHEST_PROTOCOL)

    # Control: Firing-rate model: Substitute spikes by drawing random spikes
    # according to firing rate for each inputindex
    if sorn.c.stats.control_rates:
        experiment.control_rates(sorn)

    # Report stats and close
    stats.single_report()
    stats.disable = True
    #stats.dlog.close()
    sorn.quicksave(filename=os.path.join(c.logfilepath, 'net.pickle'))
Exemple #2
0
# Parameters are read from the second command line argument
param = import_module(utils.param_file())
experiment_module = import_module(param.c.experiment.module)
experiment_name = param.c.experiment.name
experiment = getattr(experiment_module, experiment_name)(param)

c = param.c
c.logfilepath = utils.logfilename("") + "/"

(source, stats_single, _) = experiment.start()

sorn = Sorn(c, source)

# Create a StatsCollection and fill it with methods for all statistics
# that should be tracked (and later plotted)
stats = StatsCollection(sorn)
stats.methods = stats_single
sorn.stats = stats

# Datalog is used to store all results and parameters
stats.dlog.set_handler("*", utils.StoreToH5, utils.logfilename("result.h5"))
stats.dlog.append("c", utils.unbunchify(c))
stats.dlog.set_handler("*", utils.TextPrinter)

# Final experimental preparations
experiment.reset(sorn)

# Start stats
sorn.stats.start()
sorn.stats.clear()
Exemple #3
0
    # Prepare experiment
    experiment = getattr(experiment_module,
                         experiment_name)(param,
                                          cluster_param=experiment_param)
    # Save current parameter for logging
    c.cluster.current_param = current_param

    # Start experiment
    (source, _, stats_cluster) = experiment.start()

    sorn = Sorn(c, source)

    # Create a StatsCollection and fill it with methods for all
    # statistics that should be tracked (and later plotted)
    stats = StatsCollection(sorn, dlog)
    stats.methods = stats_cluster
    sorn.stats = stats

    # Run experiments
    experiment.reset(sorn)
    sorn.stats.start()
    dlog.progress("Start inner loop")
    for n in range(c.N_iterations):
        experiment.reset(sorn)
        stats.clear()

        dlog.progress("Inner Iteration %d of %d at param %.3f" %
                      (n + 1, c.N_iterations, tmp))

        pickle_objects = experiment.run(sorn)
Exemple #4
0
     experiment_param = c.cluster.vary_param
 
 # Prepare experiment
 experiment = getattr(experiment_module,experiment_name)(param,
                                      cluster_param=experiment_param) 
 # Save current parameter for logging
 c.cluster.current_param = current_param
 
 # Start experiment
 (source,_,stats_cluster) = experiment.start()
 
 sorn = Sorn(c,source)
 
 # Create a StatsCollection and fill it with methods for all 
 # statistics that should be tracked (and later plotted)
 stats = StatsCollection(sorn,dlog)
 stats.methods = stats_cluster
 sorn.stats = stats
 
 # Run experiments
 experiment.reset(sorn)
 sorn.stats.start()
 dlog.progress("Start inner loop")
 for n in range(c.N_iterations):
     experiment.reset(sorn)
     stats.clear()
     
     dlog.progress("Inner Iteration %d of %d at param %.3f"%(n+1,
                                                 c.N_iterations,tmp))
                                                 
     pickle_objects = experiment.run(sorn)
Exemple #5
0
# Parameters are read from the second command line argument
param = import_module(utils.param_file())
experiment_module = import_module(param.c.experiment.module)
experiment_name = param.c.experiment.name
experiment = getattr(experiment_module, experiment_name)(param)

c = param.c
c.logfilepath = utils.logfilename('') + '/'

(source, stats_single, _) = experiment.start()

sorn = Sorn(c, source)

# Create a StatsCollection and fill it with methods for all statistics
# that should be tracked (and later plotted)
stats = StatsCollection(sorn)
stats.methods = stats_single
sorn.stats = stats

# Datalog is used to store all results and parameters
stats.dlog.set_handler('*', utils.StoreToH5, utils.logfilename("result.h5"))
stats.dlog.append('c', utils.unbunchify(c))
stats.dlog.set_handler('*', utils.TextPrinter)

# Final experimental preparations
experiment.reset(sorn)

# Start stats
sorn.stats.start()
sorn.stats.clear()