Commit fbed93ec authored by Jean Ibarz's avatar Jean Ibarz
Browse files

Removed randomization process in generate_augmented_labelled_dataset(), at...

Removed randomization process in generate_augmented_labelled_dataset(), at this process is now done inside the model.
parent b2d41cb7
...@@ -96,7 +96,7 @@ def generate_augmented_labelled_dataset(signals, labels, convolve_mode='valid', ...@@ -96,7 +96,7 @@ def generate_augmented_labelled_dataset(signals, labels, convolve_mode='valid',
if sounds is None: if sounds is None:
for i in range(n_augment): for i in range(n_augment):
for j, signal in enumerate(signals): for j, signal in enumerate(signals):
augmented_signals.append([data_generator(signal)]) augmented_signals.append([signal])
for i_label, label in enumerate(labels): for i_label, label in enumerate(labels):
augmented_labels.append(label) augmented_labels.append(label)
else: else:
...@@ -107,12 +107,11 @@ def generate_augmented_labelled_dataset(signals, labels, convolve_mode='valid', ...@@ -107,12 +107,11 @@ def generate_augmented_labelled_dataset(signals, labels, convolve_mode='valid',
signal, label = signal_label signal, label = signal_label
if j % len(sounds) == 0: if j % len(sounds) == 0:
np.random.shuffle(i_sounds) np.random.shuffle(i_sounds)
randomized_hrir = data_generator(signal)
sound = np.zeros(shape=[len(sounds[0]), n_channels]) sound = np.zeros(shape=[len(sounds[0]), n_channels])
new_signals = [] new_signals = []
for i_channel in range(n_channels): for i_channel in range(n_channels):
sound[0:n_samples, i_channel] = sounds[j % len(sounds)][0:n_samples] sound[0:n_samples, i_channel] = sounds[j % len(sounds)][0:n_samples]
convolved_sound = scipy.signal.convolve(in1=sound[:, i_channel], in2=randomized_hrir[:, i_channel], convolved_sound = scipy.signal.convolve(in1=sound[:, i_channel], in2=signal[:, i_channel],
mode=convolve_mode, mode=convolve_mode,
method='auto') method='auto')
new_signals.append(convolved_sound) new_signals.append(convolved_sound)
......
...@@ -56,7 +56,7 @@ if __name__ == '__main__': ...@@ -56,7 +56,7 @@ if __name__ == '__main__':
if not 'convolve_mode' in exp_config.keys() or exp_config['convolve_mode'] == 'valid': if not 'convolve_mode' in exp_config.keys() or exp_config['convolve_mode'] == 'valid':
# the valid part from the convolved sound is sound[len(hrir)-1:-len(hrir)+1] # the valid part from the convolved sound is sound[len(hrir)-1:-len(hrir)+1]
# hence we have to do len(hrir)-1 left and right zero padding so that the dirac belong to the result # hence we have to do len(hrir)-1 left and right zero padding so that the dirac belong to the result
n_zeros = 512-1+exp_config['model_config']['random_shift']['maxval'] n_zeros = 512-1
zeros = np.zeros(shape=(2, n_zeros)) zeros = np.zeros(shape=(2, n_zeros))
sounds = np.concatenate([zeros, np.ones(shape=(2, 1)), zeros], axis=1) sounds = np.concatenate([zeros, np.ones(shape=(2, 1)), zeros], axis=1)
training_sounds, test_sounds = np.array_split(sounds, 2, axis=0) training_sounds, test_sounds = np.array_split(sounds, 2, axis=0)
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment