mrpep / SpecAugment

A minimalistic Tensorflow 2.x Keras layer which applies SpecAugment to its input
Apache License 2.0
6 stars 2 forks source link

Improve Performance #1

Open Joemgu7 opened 2 years ago

Joemgu7 commented 2 years ago

I suggest replacing tf.map_fn on line 74 by tf.vectorized_map, as this provides a considerable speedup (or maybe make it an additional option to choose from for compatibility).

mrpep commented 2 years ago

Thanks for the suggestion! I tried replacing it but when I test it in the colab notebook, all the batch instances have the same gaps, so I think that it is not vectorizing well the random ops. I will take a deeper look when I have some free time.

image

Joemgu7 commented 2 years ago

Thanks for the report, I hadn't noticed that the masks where the same on every output. I investigated too and think that it's more likely a concurrency issue because all instances of make_gap in a batch that is being processed are assigned to the same mask. therefore the same mask gets applied to every output (this is only an assumption). I tried fixing it but I'm running into some issues. Will get back if I make any meaningful progress.