Signal Processing (DSP) functionality

133 views
Skip to first unread message

Piyush Singh

unread,
Jan 2, 2019, 8:45:10 AM1/2/19
to TensorFlow.js Discussion
With the addition of tf.spectral.fft, tf.spectral.ifft it becomes compelling to add the following functionality that is common to DSP synthesis and analysis applications:

  1. Spectral shift similar to scipy.fftpack.fftshift
  2. Complex phase angle like numpy.angle
  3. Phase angle unwrap like numpy.unwrap
  4. Discrete difference like numpy.diff
  5. Hilbert transform like scipy.signal.hilbert

To this end, is there any objection to adding the following functions:

  1. tf.spectral.fftshift
  2. tf.spectral.angle
  3. tf.spectral.unwrap
  4. tf.spectral.diff
  5. tf.spectral.hilbert

I'll happy to implement these if given the go ahead.



Shanqing Cai

unread,
Jan 2, 2019, 11:45:44 PM1/2/19
to TensorFlow.js Discussion
Hi Piyush,

Thank you for the proposal! I think these are all good to have and will be useful for people working on DSP-related projects in the browser. See my detailed comments below

1. Spectral shift. In general, we aim at parity with the Python API of TensorFlow. fftshift is not in Python TensorFlow yet. I think it makes sense to add it in a separate repo and NPM package first. If it becomes popular in the future, we can add them to TF.js, coordinating with the Python side.
2. Complex phase angle. This is relatively straightforward and should be okay to implemented in a way consistent with tf.math.angle in Python (https://www.tensorflow.org/api_docs/python/tf/math/angle). We don't have tf.angle in TF.js yet.
3. Phase angle unwrap: Similar to spectral shift, I suggest implementing it in a separate repo first.
4. Discrete difference: Interestingly, there is no equivalent of such a simple function in Python tensorflow. I'm actually supportive of having tf.diff in TF.js while breaking parity with Python in this case. Doing it in a way consistent with numpy seems fine to me.
5. Hilbert transform: Similar to spectral shift, let's implement it in a separate repo first.

Best regards,
Shanqing
Reply all
Reply to author
Forward
0 new messages