agent/DQ_agent.py
def predict_action(self,
        frames: np.ndarray,
        exploration_rate: float
    ) -> int:
        """
        Predict an action from a stack of frames.

        Args:
            frames: the stack of frames to predict Q values from
            exploration_rate: the exploration rate for epsilon greedy selection

        Returns:
            the predicted optimal action based on the frames
        """

        if np.random.random() < exploration_rate:
            # select a random action and return it
            return self.env.action_space.sample()
        else:
            # reshape the frames to pass through the loss network
            frames = frames[np.newaxis, :, :, :]
            # predict the values of each action
            actions = self.model.predict([frames, self.predict_mask], batch_size=1)
            # return the action with the highest estimated future reward
            return np.argmax(actions)

        Predict an action from a stack of frames.

        Args:
            frames: the stack of frames to predict Q values from
            exploration_rate: the exploration rate for epsilon greedy selection

        Returns:
            the predicted optimal action based on the frames
        
Predict an action from a stack of frames.
Predict an action from a stack of frames .
def predict_action(self,
        frames: np.ndarray,
        exploration_rate: float
    ) -> int:
        if np.random.random() < exploration_rate:
            return self.env.action_space.sample()
        else:
            frames = frames[np.newaxis, :, :, :]
            actions = self.model.predict([frames, self.predict_mask], batch_size=1)
            return np.argmax(actions)
def predict_action ( self , frames : np . ndarray , exploration_rate : float ) -> int : if np . random . random ( ) < exploration_rate : return self . env . action_space . sample ( ) else : frames = frames [ np . newaxis , : , : , : ] actions = self . model . predict ( [ frames , self . predict_mask ] , batch_size = 1 ) return np . argmax ( actions )
Predict an action from a stack of frames.
Predict an action from a stack of frames .
"""
        Predict an action from a stack of frames.

        Args:
            frames: the stack of frames to predict Q values from
            exploration_rate: the exploration rate for epsilon greedy selection

        Returns:
            the predicted optimal action based on the frames
        """ # select a random action and return it # reshape the frames to pass through the loss network # predict the values of each action # return the action with the highest estimated future reward
the predicted optimal action based on the frames
the predicted optimal action based on the frames
self
frames
np.ndarray
the stack of frames to predict Q values from
the stack of frames to predict Q values from
exploration_rate
float
the exploration rate for epsilon greedy selection
the exploration rate for epsilon greedy selection