Switch to unified view

a b/dataset/create_augmented_dataset.py
1
import numpy as np
2
3
def create_augmented_dataset(raw_dataset, window_size = 512, stride = 64, verbose=False):
4
    augmented_dataset = { }
5
6
    for s,Xset_raw in raw_dataset.items():
7
        
8
        if (verbose):
9
            print('Processing set ' + s)
10
11
        total_points = Xset_raw.shape[1]
12
13
        # no. of examples generated from single training example using sliding window
14
        # = floor((total_points - window_size) / stride) + 1
15
        iterations = ((total_points - window_size) // stride) + 1
16
17
        for x_raw in Xset_raw:
18
19
            for i in range(iterations):
20
                window_slice_from = i*stride
21
                window_slice_to = i*stride + window_size
22
23
                if (s in augmented_dataset):
24
                    augmented_dataset[s] = np.append(augmented_dataset[s], [x_raw[window_slice_from:window_slice_to]], axis=0)
25
                else:
26
                    augmented_dataset[s] = np.array([x_raw[window_slice_from:window_slice_to]])
27
28
    
29
    if (verbose):
30
        print('Done.')
31
    return augmented_dataset