agent/replay/replay_queue.py
def sample(self, size: int=32) -> bool:
        """
        Return a random sample of items from the queue.
        Args:
            size: the number of items to sample and return
        Returns:
            A random sample from the queue sampled uniformly
        """
        # initialize lists for each component of the batch
        s =  [None] * size
        a =  [None] * size
        r =  [None] * size
        d =  [None] * size
        s2 = [None] * size
        # iterate over the indexes and copy references to the arrays
        for batch, sample in enumerate(np.random.randint(0, self.top, size)):
            _s, _a, _r, _d, _s2 = self.queue[sample]
            s[batch] = np.array(_s, copy=False)
            a[batch] = _a
            r[batch] = _r
            d[batch] = _d
            s2[batch] = np.array(_s2, copy=False)
        # convert the lists to arrays for returning for training
        return (
            np.array(s),
            np.array(a, dtype=np.uint8),
            np.array(r, dtype=np.int8),
            np.array(d, dtype=np.bool),
            np.array(s2),
        )

        Return a random sample of items from the queue.
        Args:
            size: the number of items to sample and return
        Returns:
            A random sample from the queue sampled uniformly
        
Return a random sample of items from the queue.
Return a random sample of items from the queue .
def sample(self, size: int=32) -> bool:
        s =  [None] * size
        a =  [None] * size
        r =  [None] * size
        d =  [None] * size
        s2 = [None] * size
        for batch, sample in enumerate(np.random.randint(0, self.top, size)):
            _s, _a, _r, _d, _s2 = self.queue[sample]
            s[batch] = np.array(_s, copy=False)
            a[batch] = _a
            r[batch] = _r
            d[batch] = _d
            s2[batch] = np.array(_s2, copy=False)
        return (
            np.array(s),
            np.array(a, dtype=np.uint8),
            np.array(r, dtype=np.int8),
            np.array(d, dtype=np.bool),
            np.array(s2),
        )
def sample ( self , size : int = 32 ) -> bool : s = [ None ] * size a = [ None ] * size r = [ None ] * size d = [ None ] * size s2 = [ None ] * size for batch , sample in enumerate ( np . random . randint ( 0 , self . top , size ) ) : _s , _a , _r , _d , _s2 = self . queue [ sample ] s [ batch ] = np . array ( _s , copy = False ) a [ batch ] = _a r [ batch ] = _r d [ batch ] = _d s2 [ batch ] = np . array ( _s2 , copy = False ) return ( np . array ( s ) , np . array ( a , dtype = np . uint8 ) , np . array ( r , dtype = np . int8 ) , np . array ( d , dtype = np . bool ) , np . array ( s2 ) , )
Return a random sample of items from the queue.
Return a random sample of items from the queue .
"""
        Return a random sample of items from the queue.
        Args:
            size: the number of items to sample and return
        Returns:
            A random sample from the queue sampled uniformly
        """ # initialize lists for each component of the batch # iterate over the indexes and copy references to the arrays # convert the lists to arrays for returning for training
A random sample from the queue sampled uniformly
A random sample from the queue sampled uniformly
self
size
int
the number of items to sample and return
the number of items to sample and return