Package topo :: Package commands :: Module basic
[hide private]
[frames] | no frames]

Module basic

source code

High-level user-level commands controlling the entire simulation. $Id: basic.py 8026 2008-02-19 14:30:05Z ceball $


Version: $Revision: 8026 $

Functions [hide private]
 
save_input_generators()
Save a copy of the active_sim's current input_generators for all GeneratorSheets.
source code
 
restore_input_generators()
Restore previously saved input_generators for all of topo.sim's GeneratorSheets.
source code
 
pattern_present(inputs={}, duration=1.0, plastic=False, overwrite_previous=False, apply_output_fn=True)
Present the specified test patterns for the specified duration.
source code
 
save_snapshot(snapshot_name=None, xml=False)
Save a snapshot of the network's current state.
source code
 
load_snapshot(snapshot_name)
Load the simulation stored in snapshot_name.
source code
 
save_script_repr(script_name=None)
Save the current simulation as a Topographica script.
source code
 
default_analysis_function()
Basic example of an analysis command for run_batch; users are likely to need something similar but highly customized.
source code
 
run_batch(script_file, output_directory='Output', analysis_fn=<function default_analysis_function at 0xa228cdc>, times=[50, 100, 500, 1000, 2000, 3000, 4000, 5000, 10000], **params)
Run a Topographica simulation in batch mode.
source code
 
wipe_out_activity()
Resets activity of all Sheets and their connections to zero.
source code
Variables [hide private]
  default_analysis_plotgroups = ['Activity', 'Orientation Prefer...
Function Details [hide private]

pattern_present(inputs={}, duration=1.0, plastic=False, overwrite_previous=False, apply_output_fn=True)

source code 

Present the specified test patterns for the specified duration.

Given a set of input patterns (dictionary of GeneratorSheetName:PatternGenerator pairs), installs them into the specified GeneratorSheets, runs the simulation for the specified length of time, then restores the original patterns and the original simulation time. Thus this input is not considered part of the regular simulation, and is usually for testing purposes.

If a simulation is not provided, the active simulation, if one exists, is requested.

If this process is interrupted by the user, the temporary patterns may still be installed on the retina.

If overwrite_previous is true, the given inputs overwrite those previously defined.

If plastic is False, overwrites the existing values of Sheet.plastic to disable plasticity, then reenables plasticity.

save_snapshot(snapshot_name=None, xml=False)

source code 

Save a snapshot of the network's current state.

The snapshot is saved as a gzip-compressed Python binary pickle.

(xml snapshots are currently experimental, and will not be useful for most users.)

As this function uses Python's 'pickle' module, it is subject to the same limitations (see the pickle module's documentation) - with the notable exception of class attributes. Python does not pickle class attributes, but this function stores class attributes of any ParameterizedObject class that is declared within the topo package. See the topo.base.PicklableClassAttributes class for more information.

save_script_repr(script_name=None)

source code 

Save the current simulation as a Topographica script.

Generates a script that, if run, would generate a simulation with the same architecture as the one currently in memory. This can be useful when defining networks in place, so that the same general configuration can be recreated later. It also helps when comparing two similar networks generated with different scripts, so that the corresponding items can be matched rigorously.

Note that the result of this operation is usually just a starting point for further editing, because it will not usually be runnable as-is (for instance, some parameters may not have runnable representations). Even so, this is usually a good start.

run_batch(script_file, output_directory='Output', analysis_fn=<function default_analysis_function at 0xa228cdc>, times=[50, 100, 500, 1000, 2000, 3000, 4000, 5000, 10000], **params)

source code 

Run a Topographica simulation in batch mode.

Features:

  • Generates a unique, well-defined name for each 'experiment' (i.e. simulation run) based on the date, script file, and parameter settings
  • Allows parameters to be varied on the command-line, to allow comparing various settings
  • Saves a script capturing the simulation state periodically, to preserve parameter values from old experiments and to allow them to be reproduced exactly later
  • Can perform user-specified analysis routines periodically, to monitor the simulation as it progresses.
  • Stores commandline output (stdout) in the output directory

A typical use of this function is for remote execution of a large number of simulations with different parameters, often on remote machines (such as clusters).

The script_file parameter defines the .ty script we want to run in batch mode. The output_directory defines the root directory in which a unique individual directory will be created for this particular run. The optional analysis_fn can be any python function to be called at each of the simulation iterations defined in the analysis times list. This function should perform whatever analysis of the simulation you want to perform, such as plotting or calculating some statistics. The analysis_fn should avoid using any GUI functions (i.e., should not import anything from topo.tkgui), and it should save all of its results into files.

Any other optional parameters supplied will be set in the main namespace before any scripts are run. They will also be used to construct a unique topo.sim.name for the file, and they will be encoded into the simulation directory name, to make it clear how each simulation differs from the others.


Variables Details [hide private]

default_analysis_plotgroups

Value:
['Activity', 'Orientation Preference']