autorl/agents.py
def _batch(self, data, q_freeze):
        """
        Construct a batch for learning using the provided tuples and
        the action value function.
        :param data:
        :param q_freeze:
        :return:
        """

        states, actions, rewards, states_prime = zip(*data)
        state_shape = [len(data)] + self._state_dim
        action_shape = [len(data), self._action_dim]

        # get the current q values for the current state and next
        # state over the entire batch simultaneously
        state_array = np.array(states).reshape(state_shape)
        state_prime_array = np.array(states_prime).reshape(state_shape)
        target_array = self.q_eval(state_array, freeze_flag=q_freeze is not None,
                                   reshape=action_shape)
        target_prime_array = self.q_eval(state_prime_array, freeze_flag=q_freeze is not None,
                                         reshape=action_shape)

        # iterate and update target array with rewards plus
        # the discounted max over the next state's q values
        for i in range(target_prime_array.shape[0]):
            # place the rewards in the index associated with the action taken.
            # the rest of the targets are the existing q values (so they aren't involved
            # when taking the gradient wrt the loss and only the action taken gets updated)
            target_array[i, actions[i]] = rewards[i] + self._discount*np.max(target_prime_array[i,:])

        return state_array, target_array

        Construct a batch for learning using the provided tuples and
        the action value function.
        :param data:
        :param q_freeze:
        :return:
        
Construct a batch for learning using the provided tuples and
the action value function.
Construct a batch for learning using the provided tuples and the action value function .
def _batch(self, data, q_freeze):
        states, actions, rewards, states_prime = zip(*data)
        state_shape = [len(data)] + self._state_dim
        action_shape = [len(data), self._action_dim]
        state_array = np.array(states).reshape(state_shape)
        state_prime_array = np.array(states_prime).reshape(state_shape)
        target_array = self.q_eval(state_array, freeze_flag=q_freeze is not None,
                                   reshape=action_shape)
        target_prime_array = self.q_eval(state_prime_array, freeze_flag=q_freeze is not None,
                                         reshape=action_shape)
        for i in range(target_prime_array.shape[0]):
            target_array[i, actions[i]] = rewards[i] + self._discount*np.max(target_prime_array[i,:])
        return state_array, target_array
def _batch ( self , data , q_freeze ) : states , actions , rewards , states_prime = zip ( * data ) state_shape = [ len ( data ) ] + self . _state_dim action_shape = [ len ( data ) , self . _action_dim ] state_array = np . array ( states ) . reshape ( state_shape ) state_prime_array = np . array ( states_prime ) . reshape ( state_shape ) target_array = self . q_eval ( state_array , freeze_flag = q_freeze is not None , reshape = action_shape ) target_prime_array = self . q_eval ( state_prime_array , freeze_flag = q_freeze is not None , reshape = action_shape ) for i in range ( target_prime_array . shape [ 0 ] ) : target_array [ i , actions [ i ] ] = rewards [ i ] + self . _discount * np . max ( target_prime_array [ i , : ] ) return state_array , target_array
Construct a batch for learning using the provided tuples and
the action value function.
Construct a batch for learning using the provided tuples and the action value function .
"""
        Construct a batch for learning using the provided tuples and
        the action value function.
        :param data:
        :param q_freeze:
        :return:
        """ # get the current q values for the current state and next # state over the entire batch simultaneously # iterate and update target array with rewards plus # the discounted max over the next state's q values # place the rewards in the index associated with the action taken. # the rest of the targets are the existing q values (so they aren't involved # when taking the gradient wrt the loss and only the action taken gets updated)
None
self
data
None
q_freeze
None