Пример #1
0
 def _gen(data):
     """Makes a generator out of a structure of NumPy/EagerTensors."""
     index_array = np.arange(num_samples)
     for _ in range(epochs):
         if shuffle:
             np.random.shuffle(index_array)
         batches = generic_utils.make_batches(num_samples, batch_size)
         for (batch_start, batch_end) in batches:
             batch_ids = index_array[batch_start:batch_end]
             flat_batch_data = training_utils.slice_arrays(
                 nest.flatten(data), batch_ids, contiguous=(not shuffle))
             yield nest.pack_sequence_as(data, flat_batch_data)
Пример #2
0
 def _gen(data):
   """Makes a generator out of a structure of NumPy/EagerTensors."""
   index_array = np.arange(num_samples)
   for _ in range(epochs):
     if shuffle:
       np.random.shuffle(index_array)
     batches = generic_utils.make_batches(num_samples, batch_size)
     for (batch_start, batch_end) in batches:
       batch_ids = index_array[batch_start:batch_end]
       flat_batch_data = training_utils.slice_arrays(
           nest.flatten(data), batch_ids, contiguous=(not shuffle))
       yield nest.pack_sequence_as(data, flat_batch_data)
Пример #3
0
 def slice_array(data):
   return training_utils.slice_arrays(data, ind.numpy(),
                                      contiguous=contiguous)