woodsja

A3C example

Nov 9th, 2018
399
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.58 KB | None | 0 0
  1.     with tf.variable_scope(scope):
  2.       # get size of features from action_spec and observation_spec
  3.       nonspatial_size = 0
  4.       spatial_features = ['feature_minimap', 'feature_screen']
  5.       initially_zero_features = {'cargo': 500, 'multi_select': 500, 'build_queue': 10, 'single_select': 1}
  6.       for feature_name, feature_dim in observation_spec:
  7.         if feature_name not in spatial_features:
  8.           if feature_name == 'available_actions':
  9.             feature_size = len(action_spec.functions)
  10.           elif feature_name in initially_zero_features:
  11.             feature_size = initially_zero_features[feature_name] * feature_dim[1]
  12.           else:
  13.             feature_size = 1
  14.             for dim in feature_dim:
  15.               feature_size *= dim
  16.           nonspatial_size += feature_size
  17.       screen_channels = observation_spec['screen'][0]
  18.       minimap_channels = observation_spec['minimap'][0]
  19.  
  20.  
  21. Old data type for observation_spec was dict-based but I don't know the exact arrangement without reading through the old changelogs.
  22.  
  23. New data type for observation_spec is a tuple like this:
  24.  
  25. <class 'tuple'>: ({'action_result': (0,), 'alerts': (0,), 'available_actions': (0,), 'build_queue': (0, 7), 'cargo': (0, 7), 'cargo_slots_available': (1,), 'control_groups': (10, 2), 'game_loop': (1,), 'last_actions': (0,), 'multi_select': (0, 7), 'player': (11,), 'score_cumulative': (13,), 'single_select': (0, 7), 'feature_screen': (17, 84, 84), 'feature_minimap': (7, 64, 64), 'feature_units': (0, 26)},)
  26.  
  27. Data in the tuple observation_spec is addressable by [0].action_result[0]
Advertisement
Add Comment
Please, Sign In to add comment