Example #1
0
 def __init__(self, nvec):
     """
     nvec: vector of counts of each categorical variable
     """
     self.nvec = np.asarray(nvec, dtype=np.int32)
     assert self.nvec.ndim == 1, 'nvec should be a 1d array (or list) of ints'
     Space.__init__(self, (self.nvec.size, ), np.int8)
Example #2
0
 def __init__(self, spaces):
     if isinstance(spaces, dict):
         spaces = OrderedDict(sorted(list(spaces.items())))
     if isinstance(spaces, list):
         spaces = OrderedDict(spaces)
     self.spaces = spaces
     Space.__init__(self, None, None) # None for shape and dtype, since it'll require special handling
Example #3
0
 def __init__(self,
               n,
               low=None,
               high=None):
   self._n = n
   self._low = low or -10000.0
   self._high = high or 100000.0
   Space.__init__(self, shape=(n,))
Example #4
0
 def __init__(self,
              n,
              low=None,
              high=None):
   self._n = n
   self._low = low
   self._high = high
   Space.__init__(self, shape=(n,))
Example #5
0
 def __init__(self, spaces):
     if isinstance(spaces, dict):
         spaces = OrderedDict(sorted(list(spaces.items())))
     if isinstance(spaces, list):
         spaces = OrderedDict(spaces)
     self.spaces = spaces
     Space.__init__(
         self, None, None
     )  # None for shape and dtype, since it'll require special handling
Example #6
0
File: box.py Project: joschu/gym
 def __init__(self, low=None, high=None, shape=None, dtype=np.float32):
     """
     Two kinds of valid input:
         Box(low=-1.0, high=1.0, shape=(3,4)) # low and high are scalars, and shape is provided
         Box(np.array(low=[-1.0,-2.0]), high=np.array([2.0,4.0])) # low and high are arrays of the same shape
     """
     if shape is None:
         assert low.shape == high.shape
         shape = low.shape
     else:
         assert np.isscalar(low) and np.isscalar(high)
         low = low + np.zeros(shape)
         high = high + np.zeros(shape)
     self.low = low.astype(dtype)
     self.high = high.astype(dtype)
     if (self.high == 255).all() and dtype != np.uint8:
         logger.warn('Box constructor got high=255 but dtype!=uint8')
     Space.__init__(self, shape, dtype)
Example #7
0
File: box.py Project: zafarali/gym
 def __init__(self, low=None, high=None, shape=None, dtype=None):
     """
     Two kinds of valid input:
         Box(low=-1.0, high=1.0, shape=(3,4)) # low and high are scalars, and shape is provided
         Box(np.array(low=[-1.0,-2.0]), high=np.array([2.0,4.0])) # low and high are arrays of the same shape
     """
     if shape is None:
         assert low.shape == high.shape
         shape = low.shape
     else:
         assert np.isscalar(low) and np.isscalar(high)
         low = low + np.zeros(shape)
         high = high + np.zeros(shape)
     if dtype is None:  # Autodetect type
         if (high == 255).all():
             dtype = np.uint8
         else:
             dtype = np.float32
         logger.warn(
             "gym.spaces.Box autodetected dtype as %s. Please provide explicit dtype."
             % dtype)
     self.low = low.astype(dtype)
     self.high = high.astype(dtype)
     Space.__init__(self, shape, dtype)
Example #8
0
 def __init__(self, n):
     self.n = n
     Space.__init__(self, (), np.int64)
Example #9
0
 def __init__(self, n):
     self.n = n
     Space.__init__(self, (self.n, ), np.int8)
Example #10
0
 def __init__(self, spaces):
     self.spaces = spaces
     Space.__init__(self, None, None)
Example #11
0
 def __init__(self, n):
     self.n = n
     Space.__init__(self, (), np.int64)
Example #12
0
 def __init__(self, n):
     self.n = n
     Space.__init__(self, (self.n,), np.int8)