Skip to content

Commit

Permalink
shifting augmentation
Browse files Browse the repository at this point in the history
  • Loading branch information
awni committed Apr 13, 2017
1 parent 196e52c commit 4d246c0
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions loader.py
Original file line number Diff line number Diff line change
Expand Up @@ -164,8 +164,17 @@ def __setstate__(self, state):
self.class_counts = state[4]

def transform(ecg):
scale = random.uniform(0.1, 5.0)
# Amplitude invariance
scale = random.uniform(0.2, 2.0)

# Lead inversion
flip = random.choice([-1.0, 1.0])

# Shifting
begin = random.randint(0, 1000)
end = -random.randint(0, 1000)
ecg = ecg[begin:end]

return ecg * flip * scale

def load_all_data(data_path, val_frac):
Expand Down Expand Up @@ -218,7 +227,7 @@ def main():

random.seed(2016)
ldr = Loader(data_path, batch_size)
logger.info("Length of training set {}".format(len(ldr.train)))
logger.info("Length of training set {}".format(len(list(ldr.train))))
logger.info("Length of validation set {}".format(len(ldr.val)))
logger.info("Output dimension {}".format(ldr.output_dim))

Expand Down

0 comments on commit 4d246c0

Please sign in to comment.