Moving Symbols  v1.0
Like Moving MNIST, but way more flexible
Public Member Functions | Public Attributes | Static Public Attributes | List of all members
moving_symbols.moving_symbols.MovingSymbolsEnvironment Class Reference

Generator that produces Moving Symbol video frames. More...

Public Member Functions

def __init__ (self, params, seed, fidelity=10, debug_options=None)
 Constructor. More...
 
def add_subscriber (self, subscriber)
 Add a subscriber of published messages. The subscriber must have a callable "process_message" method. More...
 
def send (self, _)
 
def throw (self, type=None, value=None, traceback=None)
 
def __iter__ (self)
 
def next (self)
 
def close (self)
 

Public Attributes

 params
 
 fidelity
 
 debug_options
 
 video_size
 
 cur_rng_seed
 
 symbols
 
 background
 

Static Public Attributes

 DEFAULT_PARAMS
 
 DEFAULT_DEBUG_OPTIONS
 

Detailed Description

Generator that produces Moving Symbol video frames.

This class manages a physical environment in which symbols move around. It also handles rendering of the current physical state. Renders are returned as PIL images, either in RGB or L (8-bit grayscale) mode. It implements the native Python generator interface.

The physical state is initialized based on the parameters given to the constructor (default values are supplied by DEFAULT_PARAMS). Below are the key-value pairs that can be specified:

A MovingSymbolsEnvironment object also publishes messages that describe each symbol's initialization and state; subscribers can be added with add_subscriber(). A subscriber must implement the process_message method that takes exactly one argument, a dict containing the published message. All messages have the following key-value pairs:

Below is a list of key-value pairs associated with the meta dict for each message type:

Constructor & Destructor Documentation

def moving_symbols.moving_symbols.MovingSymbolsEnvironment.__init__ (   self,
  params,
  seed,
  fidelity = 10,
  debug_options = None 
)

Constructor.

Parameters
paramsdict of parameters that define how symbols behave and are rendered. See the detailed description for this class for supported parameters.
seedSeed for the RNG (int)
fidelityHow many iterations to run in the physics simulator per step (int)
debug_optionsdict with options for visual debugging, or None if visual debugging should be turned off. The following key-value pairs are supported:
  • show_pymunk_debug, bool: Whether to use PyMunk's default drawing function
  • show_bounding_poly, bool: Whether to render PyMunk surface outlines
  • show_frame_number, bool: Whether to show the index of the frame
  • frame_number_font_size, int: Size of the frame index font
  • frame_rate, int: Frame rate of the debug visualization

Member Function Documentation

def moving_symbols.moving_symbols.MovingSymbolsEnvironment.add_subscriber (   self,
  subscriber 
)

Add a subscriber of published messages. The subscriber must have a callable "process_message" method.

Parameters
subscriberAn object with a callable "process_message" method

Member Data Documentation

moving_symbols.moving_symbols.MovingSymbolsEnvironment.DEFAULT_DEBUG_OPTIONS
static
Initial value:
1 = dict(
2  frame_number_font_size=30,
3  show_pymunk_debug=False,
4  show_bounding_poly=False,
5  show_frame_number=False,
6  frame_rate=sys.maxint
7  )
moving_symbols.moving_symbols.MovingSymbolsEnvironment.DEFAULT_PARAMS
static
Initial value:
1 = dict(
2  data_dir='../data/mnist',
3  split='training',
4  num_symbols=1,
5  video_size=(64, 64),
6  color_output=True,
7  symbol_labels=[0],
8  scale_limits=(1.0, 1.0),
9  scale_period_limits=(1, 1),
10  rotation_speed_limits=(0, 0),
11  position_speed_limits=(0, 0),
12  interacting_symbols=False,
13  scale_function_type='constant',
14  rotate_at_start=False,
15  rescale_at_start=True,
16  lateral_motion_at_start=False,
17  background_data_dir=None,
18  background_labels=None
19  )