def build_labeled_dataset(self, num_samples=100, seed=0): """Builds a problem-specific initial dataset. By default, samples sequences randomly and evaluates the problem on those sequences. Can be overwritten by problem-specific dataset generators. Args: num_samples: The number of samples to return. seed: An optional integer seed or np.random.RandomState to be used for the random number generator. Returns: A tf.data.Dataset with data_utils.DatasetSamples. """ structures = self.domain.sample_uniformly(num_samples, seed=seed) rewards = self(structures) return utils.dataset_from_tensors( data_utils.DatasetSample(structure=structures, reward=rewards))
def to_dataset(self): """Converts the population to a `tf.data.Dataset` with `DatasetSample`s.""" structures, rewards = self.to_structures_and_rewards() return utils.dataset_from_tensors( DatasetSample(structure=structures, reward=rewards))