def testSampleFromEDppDeterministic(self): """Tests that for diagonal kernels, we select points w/ eigenvalues > 0.""" edpp_indices = tf.constant([0, 0, 0, 1, 1, 1, 0, 1, 0, 0], dtype=tf.int32) eigvecs = tf.eye(10, dtype=self.param_dtype) samples = dpp_lib._sample_from_edpp(eigvecs, edpp_indices, seed=test_util.test_seed()) self.assertAllEqual(edpp_indices, samples)
def testSampleFromEDppSize(self): """Tests that the selected E-DPP size is equal to the sampled size.""" n_points = 5 edpp_indices = tf.constant( [ [0] * n_points, # Empty set. [0, 1, 0, 0, 1], [0, 0, 0, 1, 1], [1] * n_points ], dtype=tf.int32) eigenvectors = tf.random.uniform( [edpp_indices.shape[0], n_points, n_points], seed=test_util.test_seed(), dtype=self.param_dtype) samples = self.evaluate( dpp_lib._sample_from_edpp(eigenvectors, edpp_indices, seed=test_util.test_seed())) actual_sizes = np.sum(samples, axis=-1) expected_sizes = tf.reduce_sum(edpp_indices, axis=-1) self.assertAllEqual(actual_sizes, expected_sizes)