in ar-cnn/data_generator.py [0:0]
def generate_training_pairs(self):
'''
Generates Training Pairs till @training_input / @training_target have @batch_size files.
'''
# Create the training and target lists
training_input = []
training_target = []
while len(training_input) <= self.batch_size:
target_pianoroll = self.sample_list[self.sample_index]
self.sample_index = (self.sample_index + 1) % len(self.sample_list)
try:
training_data_shape = (self.bars * self.beats_per_bar *
self.beat_resolution,
self.number_of_pitches,
self.number_of_channels)
# For each pianoroll section, add or remove certain percentage of notes
add_remove_notes = AddAndRemoveAPercentageOfNotes(
sampling_lower_bound_remove=self.
sampling_lower_bound_remove,
sampling_upper_bound_remove=self.
sampling_upper_bound_remove,
sampling_lower_bound_add=self.sampling_lower_bound_add,
sampling_upper_bound_add=self.sampling_upper_bound_add)
input_pianorolls = add_remove_notes.sample(
target_pianoroll, self.samples_per_data_item)
for input_pianoroll in input_pianorolls:
training_input.append(
input_pianoroll.reshape(training_data_shape))
xor_target = np.logical_xor(input_pianoroll,
target_pianoroll)
training_target.append(
xor_target.reshape(training_data_shape))
if len(training_input) >= self.batch_size:
training_input = np.asarray(
training_input[:self.batch_size])
training_target = np.asarray(
training_target[:self.batch_size])
return training_input, training_target
except Exception as e:
print('Error generating input and target pair')
traceback.print_exc()