Distance Metrics#

Distance functions used by model loss computations.

SoftDTW#

Differentiable dynamic time warping distance (CUDA-accelerated). Used by Series2Vec for temporal distance targets.

chronocratic.models.distances.soft_dtw.soft_dtw_cuda.compute_softdtw_cuda(D, gamma, bandwidth, max_i, max_j, n_passes, R)#
Parameters:
  • seq_len – The length of the sequence (both inputs are assumed to be of the same size)

  • n_passes – 2 * seq_len - 1 (The number of anti-diagonals)

class chronocratic.models.distances.soft_dtw.soft_dtw_cuda.SoftDTW(use_cuda, gamma=1.0, normalize=False, bandwidth=None, dist_func=None)#

Bases: Module

The soft DTW implementation that optionally supports CUDA

forward(X, Y)#

Compute the soft-DTW value between X and Y :param X: One batch of examples, batch_size x seq_len x dims :param Y: The other batch of examples, batch_size x seq_len x dims :return: The computed results

chronocratic.models.distances.soft_dtw.soft_dtw_cuda.timed_run(a, b, sdtw)#

Runs a and b through sdtw, and times the forward and backward passes. Assumes that a requires gradients. :return: timing, forward result, backward result