neulab/docprompting-conala huggingface dataset:
tf.signal.mfccs_from_log_mel_spectrograms     View source on GitHub    Computes MFCCs of log_mel_spectrograms.  View aliases  Compat aliases for migration 
See Migration guide for more details. tf.compat.v1.signal.mfccs_from_log_mel_spectrograms  
tf.signal.mfccs_from_log_mel_spectrograms(
    log_mel_spectrograms, name=None
)
 Implemented with GPU-compatible ops and supports gradients. Mel-Frequency Cepstral Coefficient (MFCC) calculation consists of taking the DCT-II of a log-magnitude mel-scale spectrogram. HTK's MFCCs use a particular scaling of the DCT-II which is almost orthogonal normalization. We follow this convention. All num_mel_bins MFCCs are returned and it is up to the caller to select a subset of the MFCCs based on their application. For example, it is typical to only use the first few for speech recognition, as this results in an approximately pitch-invariant representation of the signal. For example: batch_size, num_samples, sample_rate = 32, 32000, 16000.0
# A Tensor of [batch_size, num_samples] mono PCM samples in the range [-1, 1].
pcm = tf.random.normal([batch_size, num_samples], dtype=tf.float32)

# A 1024-point STFT with frames of 64 ms and 75% overlap.
stfts = tf.signal.stft(pcm, frame_length=1024, frame_step=256,
                       fft_length=1024)
spectrograms = tf.abs(stfts)

# Warp the linear scale spectrograms into the mel-scale.
num_spectrogram_bins = stfts.shape[-1].value
lower_edge_hertz, upper_edge_hertz, num_mel_bins = 80.0, 7600.0, 80
linear_to_mel_weight_matrix = tf.signal.linear_to_mel_weight_matrix(
  num_mel_bins, num_spectrogram_bins, sample_rate, lower_edge_hertz,
  upper_edge_hertz)
mel_spectrograms = tf.tensordot(
  spectrograms, linear_to_mel_weight_matrix, 1)
mel_spectrograms.set_shape(spectrograms.shape[:-1].concatenate(
  linear_to_mel_weight_matrix.shape[-1:]))

# Compute a stabilized log to get log-magnitude mel-scale spectrograms.
log_mel_spectrograms = tf.math.log(mel_spectrograms + 1e-6)

# Compute MFCCs from log_mel_spectrograms and take the first 13.
mfccs = tf.signal.mfccs_from_log_mel_spectrograms(
  log_mel_spectrograms)[..., :13]

 


 Args
  log_mel_spectrograms   A [..., num_mel_bins] float32/float64 Tensor of log-magnitude mel-scale spectrograms.  
  name   An optional name for the operation.   
 


 Returns   A [..., num_mel_bins] float32/float64 Tensor of the MFCCs of log_mel_spectrograms.  

 


 Raises
  ValueError   If num_mel_bins is not positive.
tf.signal.overlap_and_add     View source on GitHub    Reconstructs a signal from a framed representation.  View aliases  Compat aliases for migration 
See Migration guide for more details. tf.compat.v1.signal.overlap_and_add  
tf.signal.overlap_and_add(
    signal, frame_step, name=None
)
 Adds potentially overlapping frames of a signal with shape [..., frames, frame_length], offsetting subsequent frames by frame_step. The resulting tensor has shape [..., output_size] where output_size = (frames - 1) * frame_step + frame_length

 


 Args
  signal   A [..., frames, frame_length] Tensor. All dimensions may be unknown, and rank must be at least 2.  
  frame_step   An integer or scalar Tensor denoting overlap offsets. Must be less than or equal to frame_length.  
  name   An optional name for the operation.   
 


 Returns   A Tensor with shape [..., output_size] containing the overlap-added frames of signal's inner-most two dimensions.  

 


 Raises
  ValueError   If signal's rank is less than 2, or frame_step is not a scalar integer.
tf.signal.rfft     View source on GitHub    Real-valued fast Fourier transform.  View aliases  Compat aliases for migration 
See Migration guide for more details. tf.compat.v1.signal.rfft, tf.compat.v1.spectral.rfft  
tf.signal.rfft(
    input_tensor, fft_length=None, name=None
)
 Computes the 1-dimensional discrete Fourier transform of a real-valued signal over the inner-most dimension of input. Since the DFT of a real signal is Hermitian-symmetric, RFFT only returns the fft_length / 2 + 1 unique components of the FFT: the zero-frequency term, followed by the fft_length / 2 positive-frequency terms. Along the axis RFFT is computed on, if fft_length 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: float32, float64. A float32 tensor.  
  fft_length   A Tensor of type int32. An int32 tensor of shape [1]. The FFT length.  
  Tcomplex   An optional tf.DType from: tf.complex64, tf.complex128. Defaults to tf.complex64.  
  name   A name for the operation (optional).   
 


 Returns   A Tensor of type Tcomplex.
tf.signal.rfft2d     View source on GitHub    2D real-valued fast Fourier transform.  View aliases  Compat aliases for migration 
See Migration guide for more details. tf.compat.v1.signal.rfft2d, tf.compat.v1.spectral.rfft2d  
tf.signal.rfft2d(
    input_tensor, fft_length=None, name=None
)
 Computes the 2-dimensional discrete Fourier transform of a real-valued signal over the inner-most 2 dimensions of input. Since the DFT of a real signal is Hermitian-symmetric, RFFT2D only returns the fft_length / 2 + 1 unique components of the FFT for the inner-most dimension of output: the zero-frequency term, followed by the fft_length / 2 positive-frequency terms. Along each axis RFFT2D is computed on, if fft_length 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: float32, float64. A float32 tensor.  
  fft_length   A Tensor of type int32. An int32 tensor of shape [2]. The FFT length for each dimension.  
  Tcomplex   An optional tf.DType from: tf.complex64, tf.complex128. Defaults to tf.complex64.  
  name   A name for the operation (optional).   
 


 Returns   A Tensor of type Tcomplex.
tf.signal.rfft3d     View source on GitHub    3D real-valued fast Fourier transform.  View aliases  Compat aliases for migration 
See Migration guide for more details. tf.compat.v1.signal.rfft3d, tf.compat.v1.spectral.rfft3d  
tf.signal.rfft3d(
    input_tensor, fft_length=None, name=None
)
 Computes the 3-dimensional discrete Fourier transform of a real-valued signal over the inner-most 3 dimensions of input. Since the DFT of a real signal is Hermitian-symmetric, RFFT3D only returns the fft_length / 2 + 1 unique components of the FFT for the inner-most dimension of output: the zero-frequency term, followed by the fft_length / 2 positive-frequency terms. Along each axis RFFT3D is computed on, if fft_length 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: float32, float64. A float32 tensor.  
  fft_length   A Tensor of type int32. An int32 tensor of shape [3]. The FFT length for each dimension.  
  Tcomplex   An optional tf.DType from: tf.complex64, tf.complex128. Defaults to tf.complex64.  
  name   A name for the operation (optional).   
 


 Returns   A Tensor of type Tcomplex.
tf.signal.stft     View source on GitHub    Computes the Short-time Fourier Transform of signals.  View aliases  Compat aliases for migration 
See Migration guide for more details. tf.compat.v1.signal.stft  
tf.signal.stft(
    signals, frame_length, frame_step, fft_length=None,
    window_fn=tf.signal.hann_window, pad_end=False, 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.  
  frame_step   An integer scalar Tensor. The number of samples to step.  
  fft_length   An integer scalar Tensor. The size of the FFT to apply. 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.  
  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.  
  name   An optional name for the operation.   
 


 Returns   A [..., frames, fft_unique_bins] Tensor of complex64/complex128 STFT values where fft_unique_bins is fft_length // 2 + 1 (the unique components of the FFT).  

 


 Raises
  ValueError   If signals is not at least rank 1, frame_length is not scalar, or frame_step is not scalar.
tf.signal.vorbis_window Generate a Vorbis power complementary window.  View aliases  Compat aliases for migration 
See Migration guide for more details. tf.compat.v1.signal.vorbis_window  
tf.signal.vorbis_window(
    window_length, dtype=tf.dtypes.float32, name=None
)

 


 Args
  window_length   A scalar Tensor indicating the window length to generate.  
  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.size     View source on GitHub    Returns the size of a tensor. 
tf.size(
    input, out_type=tf.dtypes.int32, name=None
)
 See also tf.shape. Returns a 0-D Tensor representing the number of elements in input of type out_type. Defaults to tf.int32. For example: 
t = tf.constant([[[1, 1, 1], [2, 2, 2]], [[3, 3, 3], [4, 4, 4]]])
tf.size(t)
<tf.Tensor: shape=(), dtype=int32, numpy=12>

 


 Args
  input   A Tensor or SparseTensor.  
  name   A name for the operation (optional).  
  out_type   (Optional) The specified non-quantized numeric output type of the operation. Defaults to tf.int32.   
 


 Returns   A Tensor of type out_type. Defaults to tf.int32.  
 Numpy Compatibility Equivalent to np.size()
tf.slice     View source on GitHub    Extracts a slice from a tensor.  View aliases  Compat aliases for migration 
See Migration guide for more details. tf.compat.v1.slice  
tf.slice(
    input_, begin, size, name=None
)
 See also tf.strided_slice. This operation extracts a slice of size size from a tensor input_ starting at the location specified by begin. The slice size is represented as a tensor shape, where size[i] is the number of elements of the 'i'th dimension of input_ that you want to slice. The starting location (begin) for the slice is represented as an offset in each dimension of input_. In other words, begin[i] is the offset into the i'th dimension of input_ that you want to slice from. Note that tf.Tensor.getitem is typically a more pythonic way to perform slices, as it allows you to write foo[3:7, :-2] instead of tf.slice(foo, [3, 0], [4, foo.get_shape()[1]-2]). begin is zero-based; size is one-based. If size[i] is -1, all remaining elements in dimension i are included in the slice. In other words, this is equivalent to setting: size[i] = input_.dim_size(i) - begin[i] This operation requires that: 0 <= begin[i] <= begin[i] + size[i] <= Di for i in [0, n] For example: t = tf.constant([[[1, 1, 1], [2, 2, 2]],
                 [[3, 3, 3], [4, 4, 4]],
                 [[5, 5, 5], [6, 6, 6]]])
tf.slice(t, [1, 0, 0], [1, 1, 3])  # [[[3, 3, 3]]]
tf.slice(t, [1, 0, 0], [1, 2, 3])  # [[[3, 3, 3],
                                   #   [4, 4, 4]]]
tf.slice(t, [1, 0, 0], [2, 1, 3])  # [[[3, 3, 3]],
                                   #  [[5, 5, 5]]]

 


 Args
  input_   A Tensor.  
  begin   An int32 or int64 Tensor.  
  size   An int32 or int64 Tensor.  
  name   A name for the operation (optional).   
 


 Returns   A Tensor the same type as input_.
tf.sort     View source on GitHub    Sorts a tensor.  View aliases  Compat aliases for migration 
See Migration guide for more details. tf.compat.v1.sort  
tf.sort(
    values, axis=-1, direction='ASCENDING', name=None
)
 Usage: import tensorflow as tf
a = [1, 10, 26.9, 2.8, 166.32, 62.3]
b = tf.sort(a,axis=-1,direction='ASCENDING',name=None)
c = tf.keras.backend.eval(b)
# Here, c = [  1.     2.8   10.    26.9   62.3  166.32]

 


 Args
  values   1-D or higher numeric Tensor.  
  axis   The axis along which to sort. The default is -1, which sorts the last axis.  
  direction   The direction in which to sort the values ('ASCENDING' or 'DESCENDING').  
  name   Optional name for the operation.   
 


 Returns   A Tensor with the same dtype and shape as values, with the elements sorted along the given axis.  

 


 Raises
  ValueError   If axis is not a constant scalar, or the direction is invalid.
Module: tf.sparse Sparse Tensor Representation. See also tf.sparse.SparseTensor. Classes class SparseTensor: Represents a sparse tensor. Functions add(...): Adds two tensors, at least one of each is a SparseTensor. bincount(...): Count the number of times an integer value appears in a tensor. concat(...): Concatenates a list of SparseTensor along the specified dimension. (deprecated arguments) cross(...): Generates sparse cross from a list of sparse and dense tensors. cross_hashed(...): Generates hashed sparse cross from a list of sparse and dense tensors. expand_dims(...): Returns a tensor with an length 1 axis inserted at index axis. eye(...): Creates a two-dimensional sparse tensor with ones along the diagonal. fill_empty_rows(...): Fills empty rows in the input 2-D SparseTensor with a default value. from_dense(...): Converts a dense tensor into a sparse tensor. map_values(...): Applies op to the .values tensor of one or more SparseTensors. mask(...): Masks elements of IndexedSlices. maximum(...): Returns the element-wise max of two SparseTensors. minimum(...): Returns the element-wise min of two SparseTensors. reduce_max(...): Computes the max of elements across dimensions of a SparseTensor. reduce_sum(...): Computes the sum of elements across dimensions of a SparseTensor. reorder(...): Reorders a SparseTensor into the canonical, row-major ordering. reset_shape(...): Resets the shape of a SparseTensor with indices and values unchanged. reshape(...): Reshapes a SparseTensor to represent values in a new dense shape. retain(...): Retains specified non-empty values within a SparseTensor. segment_mean(...): Computes the mean along sparse segments of a tensor. segment_sqrt_n(...): Computes the sum along sparse segments of a tensor divided by the sqrt(N). segment_sum(...): Computes the sum along sparse segments of a tensor. slice(...): Slice a SparseTensor based on the start and `size. softmax(...): Applies softmax to a batched N-D SparseTensor. sparse_dense_matmul(...): Multiply SparseTensor (or dense Matrix) (of rank 2) "A" by dense matrix split(...): Split a SparseTensor into num_split tensors along axis. to_dense(...): Converts a SparseTensor into a dense tensor. to_indicator(...): Converts a SparseTensor of ids into a dense bool indicator tensor. transpose(...): Transposes a SparseTensor
tf.sparse.add     View source on GitHub    Adds two tensors, at least one of each is a SparseTensor. 
tf.sparse.add(
    a, b, threshold=0
)
 If one SparseTensor and one Tensor are passed in, returns a Tensor. If both arguments are SparseTensors, this returns a SparseTensor. The order of arguments does not matter. Use vanilla tf.add() for adding two dense Tensors. The shapes of the two operands must match: broadcasting is not supported. The indices of any input SparseTensor are assumed ordered in standard lexicographic order. If this is not the case, before this step run SparseReorder to restore index ordering. If both arguments are sparse, we perform "clipping" as follows. By default, if two values sum to zero at some index, the output SparseTensor would still include that particular location in its index, storing a zero in the corresponding value slot. To override this, callers can specify threshold, indicating that if the sum has a magnitude strictly smaller than threshold, its corresponding value and index would then not be included. In particular, threshold == 0.0 (default) means everything is kept and actual thresholding happens only for a positive value. For example, suppose the logical sum of two sparse operands is (densified): [       2]
[.1     0]
[ 6   -.2]
 Then,  
threshold == 0 (the default): all 5 index/value pairs will be returned. 
threshold == 0.11: only .1 and 0 will vanish, and the remaining three index/value pairs will be returned. 
threshold == 0.21: .1, 0, and -.2 will vanish. 
 


 Args
  a   The first operand; SparseTensor or Tensor.  
  b   The second operand; SparseTensor or Tensor. At least one operand must be sparse.  
  threshold   A 0-D Tensor. The magnitude threshold that determines if an output value/index pair takes space. Its dtype should match that of the values if they are real; if the latter are complex64/complex128, then the dtype should be float32/float64, correspondingly.   
 


 Returns   A SparseTensor or a Tensor, representing the sum.  

 


 Raises
  TypeError   If both a and b are Tensors. Use tf.add() instead.
tf.sparse.concat     View source on GitHub    Concatenates a list of SparseTensor along the specified dimension. (deprecated arguments) 
tf.sparse.concat(
    axis, sp_inputs, expand_nonconcat_dims=False, name=None
)
 Warning: SOME ARGUMENTS ARE DEPRECATED: (concat_dim). They will be removed in a future version. Instructions for updating: concat_dim is deprecated, use axis instead Concatenation is with respect to the dense versions of each sparse input. It is assumed that each inputs is a SparseTensor whose elements are ordered along increasing dimension number. If expand_nonconcat_dim is False, all inputs' shapes must match, except for the concat dimension. If expand_nonconcat_dim is True, then inputs' shapes are allowed to vary among all inputs. The indices, values, and shapes lists must have the same length. If expand_nonconcat_dim is False, then the output shape is identical to the inputs', except along the concat dimension, where it is the sum of the inputs' sizes along that dimension. If expand_nonconcat_dim is True, then the output shape along the non-concat dimensions will be expand to be the largest among all inputs, and it is the sum of the inputs sizes along the concat dimension. The output elements will be resorted to preserve the sort order along increasing dimension number. This op runs in O(M log M) time, where M is the total number of non-empty values across all inputs. This is due to the need for an internal sort in order to concatenate efficiently across an arbitrary dimension. For example, if axis = 1 and the inputs are sp_inputs[0]: shape = [2, 3]
[0, 2]: "a"
[1, 0]: "b"
[1, 1]: "c"

sp_inputs[1]: shape = [2, 4]
[0, 1]: "d"
[0, 2]: "e"
 then the output will be shape = [2, 7]
[0, 2]: "a"
[0, 4]: "d"
[0, 5]: "e"
[1, 0]: "b"
[1, 1]: "c"
 Graphically this is equivalent to doing [    a] concat [  d e  ] = [    a   d e  ]
[b c  ]        [       ]   [b c          ]
 Another example, if 'axis = 1' and the inputs are sp_inputs[0]: shape = [3, 3]
[0, 2]: "a"
[1, 0]: "b"
[2, 1]: "c"

sp_inputs[1]: shape = [2, 4]
[0, 1]: "d"
[0, 2]: "e"
 if expand_nonconcat_dim = False, this will result in an error. But if expand_nonconcat_dim = True, this will result in: shape = [3, 7]
[0, 2]: "a"
[0, 4]: "d"
[0, 5]: "e"
[1, 0]: "b"
[2, 1]: "c"
 Graphically this is equivalent to doing [    a] concat [  d e  ] = [    a   d e  ]
[b    ]        [       ]   [b            ]
[  c  ]                    [  c          ]

 


 Args
  axis   Dimension to concatenate along. Must be in range [-rank, rank), where rank is the number of dimensions in each input SparseTensor.  
  sp_inputs   List of SparseTensor to concatenate.  
  name   A name prefix for the returned tensors (optional).  
  expand_nonconcat_dim   Whether to allow the expansion in the non-concat dimensions. Defaulted to False.  
  concat_dim   The old (deprecated) name for axis.  
  expand_nonconcat_dims   alias for expand_nonconcat_dim   
 


 Returns   A SparseTensor with the concatenated output.  

 


 Raises
  TypeError   If sp_inputs is not a list of SparseTensor.
tf.sparse.cross     View source on GitHub    Generates sparse cross from a list of sparse and dense tensors.  View aliases  Compat aliases for migration 
See Migration guide for more details. tf.compat.v1.sparse.cross  
tf.sparse.cross(
    inputs, name=None, separator=None
)
 For example, if the inputs are * inputs[0]: SparseTensor with shape = [2, 2]
  [0, 0]: "a"
  [1, 0]: "b"
  [1, 1]: "c"
* inputs[1]: SparseTensor with shape = [2, 1]
  [0, 0]: "d"
  [1, 0]: "e"
* inputs[2]: Tensor [["f"], ["g"]]
 then the output will be: shape = [2, 2]
[0, 0]: "a_X_d_X_f"
[1, 0]: "b_X_e_X_g"
[1, 1]: "c_X_e_X_g"
 Customized separator "Y": 
inp_0 = tf.constant([['a'], ['b']])
inp_1 = tf.constant([['c'], ['d']])
output = tf.sparse.cross([inp_0, inp_1], separator='_Y_')
output.values
<tf.Tensor: shape=(2,), dtype=string, numpy=array([b'a_Y_c', b'b_Y_d'],
  dtype=object)>

 


 Args
  inputs   An iterable of Tensor or SparseTensor.  
  name   Optional name for the op.  
  separator   A string added between each string being joined. Defaults to 'X'.   
 


 Returns   A SparseTensor of type string.
tf.sparse.cross_hashed     View source on GitHub    Generates hashed sparse cross from a list of sparse and dense tensors.  View aliases  Compat aliases for migration 
See Migration guide for more details. tf.compat.v1.sparse.cross_hashed  
tf.sparse.cross_hashed(
    inputs, num_buckets=0, hash_key=None, name=None
)
 For example, if the inputs are * inputs[0]: SparseTensor with shape = [2, 2]
  [0, 0]: "a"
  [1, 0]: "b"
  [1, 1]: "c"
* inputs[1]: SparseTensor with shape = [2, 1]
  [0, 0]: "d"
  [1, 0]: "e"
* inputs[2]: Tensor [["f"], ["g"]]
 then the output will be: shape = [2, 2]
[0, 0]: FingerprintCat64(
            Fingerprint64("f"), FingerprintCat64(
                Fingerprint64("d"), Fingerprint64("a")))
[1, 0]: FingerprintCat64(
            Fingerprint64("g"), FingerprintCat64(
                Fingerprint64("e"), Fingerprint64("b")))
[1, 1]: FingerprintCat64(
            Fingerprint64("g"), FingerprintCat64(
                Fingerprint64("e"), Fingerprint64("c")))

 


 Args
  inputs   An iterable of Tensor or SparseTensor.  
  num_buckets   An int that is >= 0. output = hashed_value%num_buckets if num_buckets > 0 else hashed_value.  
  hash_key   Integer hash_key that will be used by the FingerprintCat64 function. If not given, will use a default key.  
  name   Optional name for the op.   
 


 Returns   A SparseTensor of type int64.