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'))
# 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")) # Plot data collected by stats # ~ dest_directory = os.path.join(dest_directory,'common') experiment.plot_single(dest_directory, os.path.join("common", "result.h5")) # Display figures plt.show()
# 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')) # Plot data collected by stats #~ dest_directory = os.path.join(dest_directory,'common') experiment.plot_single(dest_directory, os.path.join('common', 'result.h5')) # Display figures plt.show()