def calculateTDErrors(self):
        # Calculates the TD-Errors in a matrix format for a set of samples = R
        # + (discount_factor*F2 - F1) * Theta
        discount_factor = self.discount_factor
        R = self.data_r[:self.samples_count, :]
        if self.use_sparse:
            F1 = sp.csr_matrix(self.all_phi_s_a[:self.samples_count, :])
            F2 = sp.csr_matrix(self.all_phi_ns_na[:self.samples_count, :])
            answer = (
                R + (discount_factor * F2 - F1) * self.representation.weight_vec.reshape(-1, 1))
            return np.squeeze(np.asarray(answer))
        else:
            F1 = self.all_phi_s_a[:self.samples_count, :]
            F2 = self.all_phi_ns_na[:self.samples_count, :]
            return R.ravel() + np.dot(discount_factor * F2 - F1, self.representation.weight_vec)
Calculate TD errors over the transition instances stored.
dataset/ETHPy150Open rlpy/rlpy/rlpy/Agents/LSPI.py/LSPI.calculateTDErrors