Dynamic time warping (DTW) is a dynamic programming algorithm used determine the optimal alignment between two sequences. This paper studies the effect of time warping severity on the performance of DTW in a systematic manner and experimentally explores several ways to improve the robustness of DTW to varying levels of time warping.
Create a new enviornment from this repo's yaml file using any package manager.
micromamba create -f environment.yaml # create env
micromamba activate DTW # activate env
After constructing the data by running notebook 01_prepare_data.ipynb
. Run experiments by running the following bash command. Batch options include: train_toy
, train_small
, train_medium
, train_full
and test_full
. Experiments results will be saved in the directory specified by output
.
The following algorithms are run via each flag:
dtw
: DTW1, DTW2, DTW3, DTW4, DTW5, DTW1_add3, DTW1_add4down
: DTW2_downsampleQuantized, DTW2_downsampleInterpolateup
: DTW2_upsampleQuantized, DTW2_upsampleInterpolateadapt
: adaptiveWeight1-2select
: selectiveTransitions2-5hop
: DTW2_adaptiveHop, DTW2_adaptiveHopDownsample
python3 02_run_experiment.py --batch train_toy \
--output_dir experiments_toy \
--dtw --down --up --adapt --select --hop
Alignment results are saved in results/
.
To alter the original Cython implementation you will need to alter dtw_algorithm.pyx
. To compile Cython, you will need to run the following command.
python3 setup.py build_ext --inplace
If there are errors with importing numpy, manually the path to the package in your environment to the CFLAG
environment variable.
export CFLAGS="-I /home/apham/ttmp/micromamba/envs/DropDTW/lib/python3.7/site-packages/numpy/core/include $CFLAGS"
Jittisa Kraprayoon, Austin Pham, and TJ Tsai. “Improving the Robustness of DTW to Global Time Warping Conditions in Audio Synchronization.” Applied Sciences, 14(4): 1459, 2024.
This material is based upon work supported by the National Science Foundation under Grant No. 2144050. Any opinions, findings, and conclusions or recommendations expressed in this material are those of the author(s) and do not necessarily reflect the views of the National Science Foundation.