neulab/docprompting-conala huggingface dataset:
tf.signal.frame     View source on GitHub    Expands signal's axis dimension into frames of frame_length.  View aliases  Compat aliases for migration 
See Migration guide for more details. tf.compat.v1.signal.frame  
tf.signal.frame(
    signal, frame_length, frame_step, pad_end=False, pad_value=0, axis=-1, name=None
)
 Slides a window of size frame_length over signal's axis dimension with a stride of frame_step, replacing the axis dimension with [frames, frame_length] frames. If pad_end is True, window positions that are past the end of the axis dimension are padded with pad_value until the window moves fully past the end of the dimension. Otherwise, only window positions that fully overlap the axis dimension are produced. For example: 
# A batch size 3 tensor of 9152 audio samples.
audio = tf.random.normal([3, 9152])

# Compute overlapping frames of length 512 with a step of 180 (frames overlap
# by 332 samples). By default, only 49 frames are generated since a frame
# with start position j*180 for j > 48 would overhang the end.
frames = tf.signal.frame(audio, 512, 180)
frames.shape.assert_is_compatible_with([3, 49, 512])

# When pad_end is enabled, the final two frames are kept (padded with zeros).
frames = tf.signal.frame(audio, 512, 180, pad_end=True)
frames.shape.assert_is_compatible_with([3, 51, 512])
 If the dimension along axis is N, and pad_end=False, the number of frames can be computed by: num_frames = 1 + (N - frame_size) // frame_step
 If pad_end=True, the number of frames can be computed by: num_frames = -(-N // frame_step) # ceiling division

 


 Args
  signal   A [..., samples, ...] Tensor. The rank and dimensions may be unknown. Rank must be at least 1.  
  frame_length   The frame length in samples. An integer or scalar Tensor.  
  frame_step   The frame hop size in samples. An integer or scalar Tensor.  
  pad_end   Whether to pad the end of signal with pad_value.  
  pad_value   An optional scalar Tensor to use where the input signal does not exist when pad_end is True.  
  axis   A scalar integer Tensor indicating the axis to frame. Defaults to the last axis. Supports negative values for indexing from the end.  
  name   An optional name for the operation.   
 


 Returns   A Tensor of frames with shape [..., num_frames, frame_length, ...].  

 


 Raises
  ValueError   If frame_length, frame_step, pad_value, or axis are not scalar.
tf.signal.hamming_window     View source on GitHub    Generate a Hamming window.  View aliases  Compat aliases for migration 
See Migration guide for more details. tf.compat.v1.signal.hamming_window  
tf.signal.hamming_window(
    window_length, periodic=True, dtype=tf.dtypes.float32, name=None
)

 


 Args
  window_length   A scalar Tensor indicating the window length to generate.  
  periodic   A bool Tensor indicating whether to generate a periodic or symmetric window. Periodic windows are typically used for spectral analysis while symmetric windows are typically used for digital filter design.  
  dtype   The data type to produce. Must be a floating point type.  
  name   An optional name for the operation.   
 


 Returns   A Tensor of shape [window_length] of type dtype.  

 


 Raises
  ValueError   If dtype is not a floating point type.
tf.signal.hann_window     View source on GitHub    Generate a Hann window.  View aliases  Compat aliases for migration 
See Migration guide for more details. tf.compat.v1.signal.hann_window  
tf.signal.hann_window(
    window_length, periodic=True, dtype=tf.dtypes.float32, name=None
)

 


 Args
  window_length   A scalar Tensor indicating the window length to generate.  
  periodic   A bool Tensor indicating whether to generate a periodic or symmetric window. Periodic windows are typically used for spectral analysis while symmetric windows are typically used for digital filter design.  
  dtype   The data type to produce. Must be a floating point type.  
  name   An optional name for the operation.   
 


 Returns   A Tensor of shape [window_length] of type dtype.  

 


 Raises
  ValueError   If dtype is not a floating point type.
tf.signal.idct     View source on GitHub    Computes the 1D Inverse Discrete Cosine Transform (DCT) of input.  View aliases  Compat aliases for migration 
See Migration guide for more details. tf.compat.v1.signal.idct, tf.compat.v1.spectral.idct  
tf.signal.idct(
    input, type=2, n=None, axis=-1, norm=None, name=None
)
 Currently Types I, II, III, IV are supported. Type III is the inverse of Type II, and vice versa. Note that you must re-normalize by 1/(2n) to obtain an inverse if norm is not 'ortho'. That is: signal == idct(dct(signal)) * 0.5 / signal.shape[-1]. When norm='ortho', we have: signal == idct(dct(signal, norm='ortho'), norm='ortho').
 


 Args
  input   A [..., samples] float32/float64 Tensor containing the signals to take the DCT of.  
  type   The IDCT type to perform. Must be 1, 2, 3 or 4.  
  n   For future expansion. The length of the transform. Must be None.  
  axis   For future expansion. The axis to compute the DCT along. Must be -1.  
  norm   The normalization to apply. None for no normalization or 'ortho' for orthonormal normalization.  
  name   An optional name for the operation.   
 


 Returns   A [..., samples] float32/float64 Tensor containing the IDCT of input.  

 


 Raises
  ValueError   If type is not 1, 2 or 3, n is not None,axisis not-1, ornormis notNoneor'ortho'`.    Scipy Compatibility Equivalent to scipy.fftpack.idct for Type-I, Type-II, Type-III and Type-IV DCT.
tf.signal.ifft Inverse fast Fourier transform.  View aliases  Compat aliases for migration 
See Migration guide for more details. tf.compat.v1.ifft, tf.compat.v1.signal.ifft, tf.compat.v1.spectral.ifft  
tf.signal.ifft(
    input, name=None
)
 Computes the inverse 1-dimensional discrete Fourier transform over the inner-most dimension of input.
 


 Args
  input   A Tensor. Must be one of the following types: complex64, complex128. A complex tensor.  
  name   A name for the operation (optional).   
 


 Returns   A Tensor. Has the same type as input.
tf.signal.ifft2d Inverse 2D fast Fourier transform.  View aliases  Compat aliases for migration 
See Migration guide for more details. tf.compat.v1.ifft2d, tf.compat.v1.signal.ifft2d, tf.compat.v1.spectral.ifft2d  
tf.signal.ifft2d(
    input, name=None
)
 Computes the inverse 2-dimensional discrete Fourier transform over the inner-most 2 dimensions of input.
 


 Args
  input   A Tensor. Must be one of the following types: complex64, complex128. A complex tensor.  
  name   A name for the operation (optional).   
 


 Returns   A Tensor. Has the same type as input.
tf.signal.ifft3d Inverse 3D fast Fourier transform.  View aliases  Compat aliases for migration 
See Migration guide for more details. tf.compat.v1.ifft3d, tf.compat.v1.signal.ifft3d, tf.compat.v1.spectral.ifft3d  
tf.signal.ifft3d(
    input, name=None
)
 Computes the inverse 3-dimensional discrete Fourier transform over the inner-most 3 dimensions of input.
 


 Args
  input   A Tensor. Must be one of the following types: complex64, complex128. A complex tensor.  
  name   A name for the operation (optional).   
 


 Returns   A Tensor. Has the same type as input.
tf.signal.ifftshift     View source on GitHub    The inverse of fftshift.  View aliases  Compat aliases for migration 
See Migration guide for more details. tf.compat.v1.signal.ifftshift  
tf.signal.ifftshift(
    x, axes=None, name=None
)
 Although identical for even-length x, the functions differ by one sample for odd-length x. For example: x = tf.signal.ifftshift([[ 0.,  1.,  2.],[ 3.,  4., -4.],[-3., -2., -1.]])
x.numpy() # array([[ 4., -4.,  3.],[-2., -1., -3.],[ 1.,  2.,  0.]])

 


 Args
  x   Tensor, input tensor.  
  axes   int or shape tuple Axes over which to calculate. Defaults to None, which shifts all axes.  
  name   An optional name for the operation.   
 


 Returns   A Tensor, The shifted tensor.  
 Numpy Compatibility Equivalent to numpy.fft.ifftshift. https://docs.scipy.org/doc/numpy/reference/generated/numpy.fft.ifftshift.html
tf.signal.inverse_mdct Computes the inverse modified DCT of mdcts.  View aliases  Compat aliases for migration 
See Migration guide for more details. tf.compat.v1.signal.inverse_mdct  
tf.signal.inverse_mdct(
    mdcts, window_fn=tf.signal.vorbis_window, norm=None, name=None
)
 To reconstruct an original waveform, the same window function should be used with mdct and inverse_mdct. Example usage: 
@tf.function
def compare_round_trip():
  samples = 1000
  frame_length = 400
  halflen = frame_length // 2
  waveform = tf.random.normal(dtype=tf.float32, shape=[samples])
  waveform_pad = tf.pad(waveform, [[halflen, 0],])
  mdct = tf.signal.mdct(waveform_pad, frame_length, pad_end=True,
                        window_fn=tf.signal.vorbis_window)
  inverse_mdct = tf.signal.inverse_mdct(mdct,
                                        window_fn=tf.signal.vorbis_window)
  inverse_mdct = inverse_mdct[halflen: halflen + samples]
  return waveform, inverse_mdct
waveform, inverse_mdct = compare_round_trip()
np.allclose(waveform.numpy(), inverse_mdct.numpy(), rtol=1e-3, atol=1e-4)
True
 Implemented with TPU/GPU-compatible ops and supports gradients.
 


 Args
  mdcts   A float32/float64 [..., frames, frame_length // 2] Tensor of MDCT bins representing a batch of frame_length // 2-point MDCTs.  
  window_fn   A callable that takes a frame_length and a dtype keyword argument and returns a [frame_length] Tensor of samples in the provided datatype. If set to None, a rectangular window with a scale of 1/sqrt(2) is used. For perfect reconstruction of a signal from mdct followed by inverse_mdct, please use tf.signal.vorbis_window, tf.signal.kaiser_bessel_derived_window or None. If using another window function, make sure that w[n]^2 + w[n + frame_length // 2]^2 = 1 and w[n] = w[frame_length - n - 1] for n = 0,...,frame_length // 2 - 1 to achieve perfect reconstruction.  
  norm   If "ortho", orthonormal inverse DCT4 is performed, if it is None, a regular dct4 followed by scaling of 1/frame_length is performed.  
  name   An optional name for the operation.   
 


 Returns   A [..., samples] Tensor of float32/float64 signals representing the inverse MDCT for each input MDCT in mdcts where samples is (frames - 1) * (frame_length // 2) + frame_length.  

 


 Raises
  ValueError   If mdcts is not at least rank 2.
tf.signal.inverse_stft     View source on GitHub    Computes the inverse Short-time Fourier Transform of stfts.  View aliases  Compat aliases for migration 
See Migration guide for more details. tf.compat.v1.signal.inverse_stft  
tf.signal.inverse_stft(
    stfts, frame_length, frame_step, fft_length=None,
    window_fn=tf.signal.hann_window, name=None
)
 To reconstruct an original waveform, a complementary window function should be used with inverse_stft. Such a window function can be constructed with tf.signal.inverse_stft_window_fn. Example: frame_length = 400
frame_step = 160
waveform = tf.random.normal(dtype=tf.float32, shape=[1000])
stft = tf.signal.stft(waveform, frame_length, frame_step)
inverse_stft = tf.signal.inverse_stft(
    stft, frame_length, frame_step,
    window_fn=tf.signal.inverse_stft_window_fn(frame_step))
 If a custom window_fn is used with tf.signal.stft, it must be passed to tf.signal.inverse_stft_window_fn: frame_length = 400
frame_step = 160
window_fn = tf.signal.hamming_window
waveform = tf.random.normal(dtype=tf.float32, shape=[1000])
stft = tf.signal.stft(
    waveform, frame_length, frame_step, window_fn=window_fn)
inverse_stft = tf.signal.inverse_stft(
    stft, frame_length, frame_step,
    window_fn=tf.signal.inverse_stft_window_fn(
       frame_step, forward_window_fn=window_fn))
 Implemented with TPU/GPU-compatible ops and supports gradients.
 


 Args
  stfts   A complex64/complex128 [..., frames, fft_unique_bins] Tensor of STFT bins representing a batch of fft_length-point STFTs where fft_unique_bins is fft_length // 2 + 1  
  frame_length   An integer scalar Tensor. The window length in samples.  
  frame_step   An integer scalar Tensor. The number of samples to step.  
  fft_length   An integer scalar Tensor. The size of the FFT that produced stfts. If not provided, uses the smallest power of 2 enclosing frame_length.  
  window_fn   A callable that takes a window length and a dtype keyword argument and returns a [window_length] Tensor of samples in the provided datatype. If set to None, no windowing is used.  
  name   An optional name for the operation.   
 


 Returns   A [..., samples] Tensor of float32/float64 signals representing the inverse STFT for each input STFT in stfts.  

 


 Raises
  ValueError   If stfts is not at least rank 2, frame_length is not scalar, frame_step is not scalar, or fft_length is not scalar.
tf.signal.inverse_stft_window_fn     View source on GitHub    Generates a window function that can be used in inverse_stft.  View aliases  Compat aliases for migration 
See Migration guide for more details. tf.compat.v1.signal.inverse_stft_window_fn  
tf.signal.inverse_stft_window_fn(
    frame_step, forward_window_fn=tf.signal.hann_window, name=None
)
 Constructs a window that is equal to the forward window with a further pointwise amplitude correction. inverse_stft_window_fn is equivalent to forward_window_fn in the case where it would produce an exact inverse. See examples in inverse_stft documentation for usage.
 


 Args
  frame_step   An integer scalar Tensor. The number of samples to step.  
  forward_window_fn   window_fn used in the forward transform, stft.  
  name   An optional name for the operation.   
 


 Returns   A callable that takes a window length and a dtype keyword argument and returns a [window_length] Tensor of samples in the provided datatype. The returned window is suitable for reconstructing original waveform in inverse_stft.
tf.signal.irfft     View source on GitHub    Inverse real-valued fast Fourier transform.  View aliases  Compat aliases for migration 
See Migration guide for more details. tf.compat.v1.signal.irfft, tf.compat.v1.spectral.irfft  
tf.signal.irfft(
    input_tensor, fft_length=None, name=None
)
 Computes the inverse 1-dimensional discrete Fourier transform of a real-valued signal over the inner-most dimension of input. The inner-most dimension of input is assumed to be the result of RFFT: the fft_length / 2 + 1 unique components of the DFT of a real-valued signal. If fft_length is not provided, it is computed from the size of the inner-most dimension of input (fft_length = 2 * (inner - 1)). If the FFT length used to compute input is odd, it should be provided since it cannot be inferred properly. Along the axis IRFFT is computed on, if fft_length / 2 + 1 is smaller than the corresponding dimension of input, the dimension is cropped. If it is larger, the dimension is padded with zeros.
 


 Args
  input   A Tensor. Must be one of the following types: complex64, complex128. A complex tensor.  
  fft_length   A Tensor of type int32. An int32 tensor of shape [1]. The FFT length.  
  Treal   An optional tf.DType from: tf.float32, tf.float64. Defaults to tf.float32.  
  name   A name for the operation (optional).   
 


 Returns   A Tensor of type Treal.
tf.signal.irfft2d     View source on GitHub    Inverse 2D real-valued fast Fourier transform.  View aliases  Compat aliases for migration 
See Migration guide for more details. tf.compat.v1.signal.irfft2d, tf.compat.v1.spectral.irfft2d  
tf.signal.irfft2d(
    input_tensor, fft_length=None, name=None
)
 Computes the inverse 2-dimensional discrete Fourier transform of a real-valued signal over the inner-most 2 dimensions of input. The inner-most 2 dimensions of input are assumed to be the result of RFFT2D: The inner-most dimension contains the fft_length / 2 + 1 unique components of the DFT of a real-valued signal. If fft_length is not provided, it is computed from the size of the inner-most 2 dimensions of input. If the FFT length used to compute input is odd, it should be provided since it cannot be inferred properly. Along each axis IRFFT2D is computed on, if fft_length (or fft_length / 2 + 1 for the inner-most dimension) is smaller than the corresponding dimension of input, the dimension is cropped. If it is larger, the dimension is padded with zeros.
 


 Args
  input   A Tensor. Must be one of the following types: complex64, complex128. A complex tensor.  
  fft_length   A Tensor of type int32. An int32 tensor of shape [2]. The FFT length for each dimension.  
  Treal   An optional tf.DType from: tf.float32, tf.float64. Defaults to tf.float32.  
  name   A name for the operation (optional).   
 


 Returns   A Tensor of type Treal.
tf.signal.irfft3d     View source on GitHub    Inverse 3D real-valued fast Fourier transform.  View aliases  Compat aliases for migration 
See Migration guide for more details. tf.compat.v1.signal.irfft3d, tf.compat.v1.spectral.irfft3d  
tf.signal.irfft3d(
    input_tensor, fft_length=None, name=None
)
 Computes the inverse 3-dimensional discrete Fourier transform of a real-valued signal over the inner-most 3 dimensions of input. The inner-most 3 dimensions of input are assumed to be the result of RFFT3D: The inner-most dimension contains the fft_length / 2 + 1 unique components of the DFT of a real-valued signal. If fft_length is not provided, it is computed from the size of the inner-most 3 dimensions of input. If the FFT length used to compute input is odd, it should be provided since it cannot be inferred properly. Along each axis IRFFT3D is computed on, if fft_length (or fft_length / 2 + 1 for the inner-most dimension) is smaller than the corresponding dimension of input, the dimension is cropped. If it is larger, the dimension is padded with zeros.
 


 Args
  input   A Tensor. Must be one of the following types: complex64, complex128. A complex tensor.  
  fft_length   A Tensor of type int32. An int32 tensor of shape [3]. The FFT length for each dimension.  
  Treal   An optional tf.DType from: tf.float32, tf.float64. Defaults to tf.float32.  
  name   A name for the operation (optional).   
 


 Returns   A Tensor of type Treal.
tf.signal.kaiser_bessel_derived_window Generate a Kaiser Bessel derived window.  View aliases  Compat aliases for migration 
See Migration guide for more details. tf.compat.v1.signal.kaiser_bessel_derived_window  
tf.signal.kaiser_bessel_derived_window(
    window_length, beta=12.0, dtype=tf.dtypes.float32, name=None
)

 


 Args
  window_length   A scalar Tensor indicating the window length to generate.  
  beta   Beta parameter for Kaiser window.  
  dtype   The data type to produce. Must be a floating point type.  
  name   An optional name for the operation.   
 


 Returns   A Tensor of shape [window_length] of type dtype.
tf.signal.kaiser_window Generate a Kaiser window.  View aliases  Compat aliases for migration 
See Migration guide for more details. tf.compat.v1.signal.kaiser_window  
tf.signal.kaiser_window(
    window_length, beta=12.0, dtype=tf.dtypes.float32, name=None
)

 


 Args
  window_length   A scalar Tensor indicating the window length to generate.  
  beta   Beta parameter for Kaiser window, see reference below.  
  dtype   The data type to produce. Must be a floating point type.  
  name   An optional name for the operation.   
 


 Returns   A Tensor of shape [window_length] of type dtype.
tf.signal.linear_to_mel_weight_matrix       View source on GitHub    Returns a matrix to warp linear scale spectrograms to the mel scale.  View aliases  Compat aliases for migration 
See Migration guide for more details. tf.compat.v1.signal.linear_to_mel_weight_matrix  
tf.signal.linear_to_mel_weight_matrix(
    num_mel_bins=20, num_spectrogram_bins=129, sample_rate=8000,
    lower_edge_hertz=125.0, upper_edge_hertz=3800.0, dtype=tf.dtypes.float32,
    name=None
)
 Returns a weight matrix that can be used to re-weight a Tensor containing num_spectrogram_bins linearly sampled frequency information from [0, sample_rate / 2] into num_mel_bins frequency information from [lower_edge_hertz, upper_edge_hertz] on the mel scale. This function follows the Hidden Markov Model Toolkit (HTK) convention, defining the mel scale in terms of a frequency in hertz according to the following formula:  $$ extrm{mel}(f) = 2595 * extrm{log}_{10}(1 + rac{f}{700})$$  In the returned matrix, all the triangles (filterbanks) have a peak value of 1.0. For example, the returned matrix A can be used to right-multiply a spectrogram S of shape [frames, num_spectrogram_bins] of linear scale spectrum values (e.g. STFT magnitudes) to generate a "mel spectrogram" M of shape [frames, num_mel_bins]. # `S` has shape [frames, num_spectrogram_bins]
# `M` has shape [frames, num_mel_bins]
M = tf.matmul(S, A)
 The matrix can be used with tf.tensordot to convert an arbitrary rank Tensor of linear-scale spectral bins into the mel scale. # S has shape [..., num_spectrogram_bins].
# M has shape [..., num_mel_bins].
M = tf.tensordot(S, A, 1)

 


 Args
  num_mel_bins   Python int. How many bands in the resulting mel spectrum.  
  num_spectrogram_bins   An integer Tensor. How many bins there are in the source spectrogram data, which is understood to be fft_size // 2 + 1, i.e. the spectrogram only contains the nonredundant FFT bins.  
  sample_rate   An integer or float Tensor. Samples per second of the input signal used to create the spectrogram. Used to figure out the frequencies corresponding to each spectrogram bin, which dictates how they are mapped into the mel scale.  
  lower_edge_hertz   Python float. Lower bound on the frequencies to be included in the mel spectrum. This corresponds to the lower edge of the lowest triangular band.  
  upper_edge_hertz   Python float. The desired top edge of the highest frequency band.  
  dtype   The DType of the result matrix. Must be a floating point type.  
  name   An optional name for the operation.   
 


 Returns   A Tensor of shape [num_spectrogram_bins, num_mel_bins].  

 


 Raises
  ValueError   If num_mel_bins/num_spectrogram_bins/sample_rate are not positive, lower_edge_hertz is negative, frequency edges are incorrectly ordered, upper_edge_hertz is larger than the Nyquist frequency.
tf.signal.mdct Computes the Modified Discrete Cosine Transform of signals.  View aliases  Compat aliases for migration 
See Migration guide for more details. tf.compat.v1.signal.mdct  
tf.signal.mdct(
    signals, frame_length, window_fn=tf.signal.vorbis_window, pad_end=False,
    norm=None, name=None
)
 Implemented with TPU/GPU-compatible ops and supports gradients.
 


 Args
  signals   A [..., samples] float32/float64 Tensor of real-valued signals.  
  frame_length   An integer scalar Tensor. The window length in samples which must be divisible by 4.  
  window_fn   A callable that takes a frame_length and a dtype keyword argument and returns a [frame_length] Tensor of samples in the provided datatype. If set to None, a rectangular window with a scale of 1/sqrt(2) is used. For perfect reconstruction of a signal from mdct followed by inverse_mdct, please use tf.signal.vorbis_window, tf.signal.kaiser_bessel_derived_window or None. If using another window function, make sure that w[n]^2 + w[n + frame_length // 2]^2 = 1 and w[n] = w[frame_length - n - 1] for n = 0,...,frame_length // 2 - 1 to achieve perfect reconstruction.  
  pad_end   Whether to pad the end of signals with zeros when the provided frame length and step produces a frame that lies partially past its end.  
  norm   If it is None, unnormalized dct4 is used, if it is "ortho" orthonormal dct4 is used.  
  name   An optional name for the operation.   
 


 Returns   A [..., frames, frame_length // 2] Tensor of float32/float64 MDCT values where frames is roughly samples // (frame_length // 2) when pad_end=False.  

 


 Raises
  ValueError   If signals is not at least rank 1, frame_length is not scalar, or frame_length is not a multiple of 4.