class_docstr: Apply SpecAugment to a Spectrogram. For more info, check the original paper at:
  https://arxiv.org/abs/1904.08779
  
  Args:
      freq_mask_param (`int`): Frequency Mask Parameter (F in the paper)
      time_mask_param (ìnt`): Time Mask Parameter (T in the paper)
      n_freq_masks (`int`): Number of frequency masks to apply (mF in the paper). By default is 1.
      n_time_masks (`int`): Number of time masks to apply (mT in the paper). By default is 1.
      mask_value (`float`): Value of the applied masks. By default is 0.
      data_format (`str`): specifies the data format of batch input/output
      **kwargs: Keyword args for the parent keras layer (e.g., `name`)
  
  Example:
      ::
  
          input_shape = (2048, 1)  # mono signal
  
          # We compute the Mel Spectrogram of the input signal
          melgram = kapre.composed.get_melspectrogram_layer(input_shape=input_shape,
                                                n_fft=1024,
                                                return_decibel=True,
                                                n_mels=256,
                                                input_data_format='channels_last',
                                                output_data_format='channels_last')
  
  
          # Now we define the SpecAugment layer. It will apply 5 masks in the frequency axis,
          # 3 masks in the time axis. The frequency mask param is 5 and the time mask param
          # is 10.
          spec_augment = SpecAugment(freq_mask_param=5,
                                     time_mask_param=10,
                                     n_freq_masks=5,
                                     n_time_masks=3)
  
          model = Sequential()
          model.add(melgram)
  
          # Add the spec_augment layer for augmentation
          model.add(spec_augment)
      ::
class_docstr_tok: ["Apply","SpecAugment","to","a","Spectrogram",".","For","more","info",",","check","the","original","paper","at",":","https",":","\/\/arxiv.org\/abs\/1904.08779","Args",":","freq_mask_param","(","`","int","`",")",":","Frequency","Mask","Parameter","(","F","in","the","paper",")","time_mask_param","(","\u00ecnt","`",")",":","Time","Mask","Parameter","(","T","in","the","paper",")","n_freq_masks","(","`","int","`",")",":","Number","of","frequency","masks","to","apply","(","mF","in","the","paper",")",".","By","default","is","1.","n_time_masks","(","`","int","`",")",":","Number","of","time","masks","to","apply","(","mT","in","the","paper",")",".","By","default","is","1.","mask_value","(","`","float","`",")",":","Value","of","the","applied","masks",".","By","default","is","0.","data_format","(","`","str","`",")",":","specifies","the","data","format","of","batch","input\/output","*","*","kwargs",":","Keyword","args","for","the","parent","keras","layer","(","e.g.",",","`","name","`",")","Example",":",":",":","input_shape","=","(","2048",",","1",")","#","mono","signal","#","We","compute","the","Mel","Spectrogram","of","the","input","signal","melgram","=","kapre.composed.get_melspectrogram_layer","(","input_shape=input_shape",",","n_fft=1024",",","return_decibel=True",",","n_mels=256",",","input_data_format='channels_last","'",",","output_data_format='channels_last","'",")","#","Now","we","define","the","SpecAugment","layer",".","It","will","apply","5","masks","in","the","frequency","axis",",","#","3","masks","in","the","time","axis",".","The","frequency","mask","param","is","5","and","the","time","mask","param","#","is","10.","spec_augment","=","SpecAugment","(","freq_mask_param=5",",","time_mask_param=10",",","n_freq_masks=5",",","n_time_masks=3",")","model","=","Sequential","(",")","model.add","(","melgram",")","#","Add","the","spec_augment","layer","for","augmentation","model.add","(","spec_augment",")",":",":"]
docstr: Generate a mask for the axis provided
  Args:
      inputs (`tuple`): A 3-tuple with the following structure:
          inputs[0] (float `Tensor`): A spectrogram. Its shape is (time, freq, ch) or (ch, time, freq)
              depending on data_format
          inputs[1] (int): The axis limit. If mask will be applied to time axis it will be `time`, if it will
              be applied to frequency axis, then it will be `freq`
          inputs[2] (int `Tensor`): The axis indices. We need this Tensor of indices to indicate where to apply
              the mask.
          inputs[3] (int): The mask param as defined in the original paper, which is the max width of the mask
              applied.
  Returns:
      (bool `Tensor`): A boolean tensor representing the mask. Its shape is (time, freq, ch) or (ch, time, freq)
          depending on inputs[0] shape (that is, the input spectrogram).
docstr_tok: ["Generate","a","mask","for","the","axis","provided","Args",":","inputs","(","`","tuple","`",")",":","A","3-tuple","with","the","following","structure",":","inputs","[","0","]","(","float","`","Tensor","`",")",":","A","spectrogram",".","Its","shape","is","(","time",",","freq",",","ch",")","or","(","ch",",","time",",","freq",")","depending","on","data_format","inputs","[","1","]","(","int",")",":","The","axis","limit",".","If","mask","will","be","applied","to","time","axis","it","will","be","`","time","`",",","if","it","will","be","applied","to","frequency","axis",",","then","it","will","be","`","freq","`","inputs","[","2","]","(","int","`","Tensor","`",")",":","The","axis","indices",".","We","need","this","Tensor","of","indices","to","indicate","where","to","apply","the","mask",".","inputs","[","3","]","(","int",")",":","The","mask","param","as","defined","in","the","original","paper",",","which","is","the","max","width","of","the","mask","applied",".","Returns",":","(","bool","`","Tensor","`",")",":","A","boolean","tensor","representing","the","mask",".","Its","shape","is","(","time",",","freq",",","ch",")","or","(","ch",",","time",",","freq",")","depending","on","inputs","[","0","]","shape","(","that","is",",","the","input","spectrogram",")","."]
code: def _generate_axis_mask(inputs):
      """
      Generate a mask for the axis provided
      Args:
          inputs (`tuple`): A 3-tuple with the following structure:
              inputs[0] (float `Tensor`): A spectrogram. Its shape is (time, freq, ch) or (ch, time, freq)
                  depending on data_format
              inputs[1] (int): The axis limit. If mask will be applied to time axis it will be `time`, if it will
                  be applied to frequency axis, then it will be `freq`
              inputs[2] (int `Tensor`): The axis indices. We need this Tensor of indices to indicate where to apply
                  the mask.
              inputs[3] (int): The mask param as defined in the original paper, which is the max width of the mask
                  applied.
      Returns:
          (bool `Tensor`): A boolean tensor representing the mask. Its shape is (time, freq, ch) or (ch, time, freq)
              depending on inputs[0] shape (that is, the input spectrogram).
      """
      x, axis_limit, axis_indices, mask_param = inputs
  
      mask_width = tf.random.uniform(
          shape=(), maxval=mask_param, dtype=tf.int32
      )
      mask_start = tf.random.uniform(
          shape=(), maxval=axis_limit - mask_width, dtype=tf.int32
      )
  
      return tf.logical_and(
          axis_indices >= mask_start,
          axis_indices <= mask_start + mask_width,
      )
  
file_path: kapre/kapre/augmentation.py
imports: import tensorflow
  from tensorflow.keras.layers import Layer
  from tensorflow.keras import backend
  from .None import backend
  from .backend import _CH_FIRST_STR, _CH_LAST_STR, _CH_DEFAULT_STR
  import numpy
label_desc: Use image node_id 2 for calling the SpecAugment obj's underlying member method code with example usage: obj._generate_axis_mask(inputs) and returns: tf