def batchBestAction(self, all_s, all_phi_s,
                        action_mask=None, useSparse=True):
        p, n = all_phi_s.shape
        a_num = self.actions_num

        if action_mask is None:
            action_mask = np.ones((p, a_num))
            for i, s in enumerate(all_s):
                action_mask[i, self.domain.possibleActions(s)] = 0

        a_num = self.actions_num
        if useSparse:
            # all_phi_s_a will be ap-by-an
            all_phi_s_a = sp.kron(np.eye(a_num, a_num), all_phi_s)
            all_q_s_a = all_phi_s_a * self.weight_vec.reshape(-1, 1)  # ap-by-1
        else:
            # all_phi_s_a will be ap-by-an
            all_phi_s_a = np.kron(np.eye(a_num, a_num), all_phi_s)
            all_q_s_a = np.dot(all_phi_s_a, self.weight_vec.T)  # ap-by-1
        all_q_s_a = all_q_s_a.reshape((a_num, -1)).T  # a-by-p
        all_q_s_a = np.ma.masked_array(all_q_s_a, mask=action_mask)
        best_action = np.argmax(all_q_s_a, axis=1)

        # Calculate the corresponding phi_s_a
        phi_s_a = self.batchPhi_s_a(
            all_phi_s,
            best_action,
            all_phi_s_a,
            useSparse)
        return best_action, phi_s_a, action_mask
Thread callback to release resources.
dataset/ETHPy150Open rlpy/rlpy/rlpy/Representations/Representation.py/Representation.batchBestAction--crossover with--dataset/ETHPy150Open openstack/ironic/ironic/conductor/task_manager.py/TaskManager._thread_release_resources