basic_utils/replay_memory.py
def sample(self):
        """
        Sample data from the memory.

        Return:
            the sampled path
        """
        idxes = self._sample_proportional(self.batch_size)
        weights = []
        for idx in idxes:
            p_sample = self._it_sum[idx] / self._it_sum.sum()
            weight = (p_sample * len(self._storage)) ** (-self._beta) if p_sample > 1e-12 else 0
            weights.append(weight)
        weights = np.array(weights)/np.sum(weights)
        encoded_sample = self._encode_sample(idxes)
        encoded_sample["weights"] = weights
        encoded_sample["idxes"] = idxes
        return encoded_sample

        Sample data from the memory.

        Return:
            the sampled path
        
Sample data from the memory.
Return:
the sampled path
Sample data from the memory . Return : the sampled path
def sample(self):
        idxes = self._sample_proportional(self.batch_size)
        weights = []
        for idx in idxes:
            p_sample = self._it_sum[idx] / self._it_sum.sum()
            weight = (p_sample * len(self._storage)) ** (-self._beta) if p_sample > 1e-12 else 0
            weights.append(weight)
        weights = np.array(weights)/np.sum(weights)
        encoded_sample = self._encode_sample(idxes)
        encoded_sample["weights"] = weights
        encoded_sample["idxes"] = idxes
        return encoded_sample
def sample ( self ) : idxes = self . _sample_proportional ( self . batch_size ) weights = [ ] for idx in idxes : p_sample = self . _it_sum [ idx ] / self . _it_sum . sum ( ) weight = ( p_sample * len ( self . _storage ) ) ** ( - self . _beta ) if p_sample > 1e-12 else 0 weights . append ( weight ) weights = np . array ( weights ) / np . sum ( weights ) encoded_sample = self . _encode_sample ( idxes ) encoded_sample [ "weights" ] = weights encoded_sample [ "idxes" ] = idxes return encoded_sample
Sample data from the memory.
Sample data from the memory .
"""
        Sample data from the memory.

        Return:
            the sampled path
        """
self