Skip to content

Commit

Permalink
Use bucketing sampler while continue_from
Browse files Browse the repository at this point in the history
  • Loading branch information
EgorLakomkin committed Jun 22, 2017
1 parent 8ffbcf5 commit b3c8055
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
2 changes: 1 addition & 1 deletion data/data_loader.py
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ def augment_audio_with_sox(path, sample_rate, tempo, gain):
with NamedTemporaryFile(suffix=".wav") as augmented_file:
augmented_filename = augmented_file.name
sox_augment_params = ["tempo", "{:.3f}".format(tempo), "gain", "{:.3f}".format(gain)]
sox_params = "sox {} -r {} -c 1 -b 16 {} {} >/dev/null 2>&1".format(path, sample_rate,
sox_params = "sox \"{}\" -r {} -c 1 -b 16 {} {} >/dev/null 2>&1".format(path, sample_rate,
augmented_filename,
" ".join(sox_augment_params))
os.system(sox_params)
Expand Down
7 changes: 7 additions & 0 deletions train.py
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,13 @@ def main():
}
for tag, val in info.items():
logger.scalar_summary(tag, val, i + 1)
if not args.no_bucketing:
print("Using bucketing sampler for the following epochs")
train_dataset = SpectrogramDatasetWithLength(audio_conf=audio_conf, manifest_filepath=args.train_manifest,
labels=labels,
normalize=True, augment=args.augment)
sampler = BucketingSampler(train_dataset)
train_loader.sampler = sampler
else:
avg_loss = 0
start_epoch = 0
Expand Down

0 comments on commit b3c8055

Please sign in to comment.