pysiglib.sig_combine_backprop

pysiglib.sig_combine_backprop#

Added in version v0.2.

sig_combine_backprop(deriv, sig1, sig2, dimension, degree, n_jobs=1)[source]#

This function is required to backpropagate through pysiglib.sig_combine. Given the derivatives of a scalar function \(F\) with respect to the result of pysiglib.sig_combine, \(\partial F / \partial S(x_1 * x_2)\), returns the derivatives of \(F\) with respect to the original two signatures, \(\partial F / \partial S(x_1)\) and \(\partial F / \partial S(x_2)\).

Parameters:
  • deriv – Derivative with respect to the combined signature, \(\partial F / \partial S(x_1 * x_2)\)

  • sig1 (numpy.ndarray | torch.tensor) – The first truncated signature

  • sig2 (numpy.ndarray | torch.tensor) – The second truncated signature. Must have the same degree and dimension as the first.

  • dimension (int) – Dimension of the underlying space, \(d\).

  • degree (int) – Truncation level of the signatures, \(N\)

  • n_jobs (int) – Number of threads to run in parallel. If n_jobs = 1, the computation is run serially. If set to -1, all available threads are used. For n_jobs below -1, (max_threads + 1 + n_jobs) threads are used. For example if n_jobs = -2, all threads but one are used.

Returns:

Derivatives with respect to sig1 and sig2

Return type:

Tuple[numpy.ndarray | torch.tensor, numpy.ndarray | torch.tensor]

Note

Ideally, any array passed to pysiglib.sig_combine_backprop should be both contiguous and own its data. If this is not the case, pysiglib.sig_combine_backprop will internally create a contiguous copy, which may be inefficient.