(self, batch_size, random_selection=False)
return states, actions, rewards, next_states, terminal
Return corresponding states, actions, rewards, terminal status, and
next_states for batch_size randomly chosen state transitions.
Return corresponding states, actions, rewards, terminal status, and
next_states for batch_size randomly chosen state transitions.
Return corresponding states actions rewards terminal status and next_states for batch_size randomly chosen state transitions .
def random_batch(self, batch_size, random_selection=False):
    """Return corresponding states, actions, rewards, terminal status, and
next_states for batch_size randomly chosen state transitions.

    """
    # Allocate the response.
    states = np.zeros((batch_size,
               self.phi_length,
               self.height,
               self.width),
              dtype='uint8')
    actions = np.zeros((batch_size), dtype='int32')
    rewards = np.zeros((batch_size), dtype=floatX)
    terminal = np.zeros((batch_size), dtype='bool')
    next_states = np.zeros((batch_size,
                self.phi_length,
                self.height,
                self.width),
                 dtype='uint8')

    count = 0
    indices = np.zeros((batch_size), dtype='int32')
      
    while count < batch_size:
      # Randomly choose a time step from the replay memory.
      index = self.rng.randint(self.bottom,
                     self.bottom + self.size - self.phi_length)

      initial_indices = np.arange(index, index + self.phi_length)
      transition_indices = initial_indices + 1
      end_index = index + self.phi_length - 1

      if np.any(self.terminal.take(initial_indices[0:-1], mode='wrap')):
        continue

      indices[count] = index

      # Add the state transition to the response.
      states[count] = self.imgs.take(initial_indices, axis=0, mode='wrap')
      actions[count] = self.actions.take(end_index, mode='wrap')
      rewards[count] = self.rewards.take(end_index, mode='wrap')
      terminal[count] = self.terminal.take(end_index, mode='wrap')
      next_states[count] = self.imgs.take(transition_indices,
                        axis=0,
                        mode='wrap')
      count += 1

    return states, actions, rewards, next_states, terminal
def random_batch ( self , batch_size , random_selection = False ) : # Allocate the response. states = np . zeros ( ( batch_size , self . phi_length , self . height , self . width ) , dtype = 'uint8' ) actions = np . zeros ( ( batch_size ) , dtype = 'int32' ) rewards = np . zeros ( ( batch_size ) , dtype = floatX ) terminal = np . zeros ( ( batch_size ) , dtype = 'bool' ) next_states = np . zeros ( ( batch_size , self . phi_length , self . height , self . width ) , dtype = 'uint8' ) count = 0 indices = np . zeros ( ( batch_size ) , dtype = 'int32' ) while count < batch_size : # Randomly choose a time step from the replay memory. index = self . rng . randint ( self . bottom , self . bottom + self . size - self . phi_length ) initial_indices = np . arange ( index , index + self . phi_length ) transition_indices = initial_indices + 1 end_index = index + self . phi_length - 1 if np . any ( self . terminal . take ( initial_indices [ 0 : - 1 ] , mode = 'wrap' ) ) : continue indices [ count ] = index # Add the state transition to the response. states [ count ] = self . imgs . take ( initial_indices , axis = 0 , mode = 'wrap' ) actions [ count ] = self . actions . take ( end_index , mode = 'wrap' ) rewards [ count ] = self . rewards . take ( end_index , mode = 'wrap' ) terminal [ count ] = self . terminal . take ( end_index , mode = 'wrap' ) next_states [ count ] = self . imgs . take ( transition_indices , axis = 0 , mode = 'wrap' ) count += 1 return states , actions , rewards , next_states , terminal