class_docstr: Class that manages the training loop. See speechbrain.core.Brain.
class_docstr_tok: ["Class","that","manages","the","training","loop",".","See","speechbrain.core.Brain","."]
docstr: Apply masking to convert from noisy waveforms to enhanced signals.
  
  Arguments
  ---------
  batch : PaddedBatch
      This batch object contains all the relevant tensors for computation.
  stage : sb.Stage
      One of sb.Stage.TRAIN, sb.Stage.VALID, or sb.Stage.TEST.
  
  Returns
  -------
  predictions : dict
      A dictionary with keys {"spec", "wav"} with predicted features.
docstr_tok: ["Apply","masking","to","convert","from","noisy","waveforms","to","enhanced","signals",".","Arguments","--","--","--","--","-","batch",":","PaddedBatch","This","batch","object","contains","all","the","relevant","tensors","for","computation",".","stage",":","sb.Stage","One","of","sb.Stage.TRAIN",",","sb.Stage.VALID",",","or","sb.Stage.TEST",".","Returns","--","--","--","-","predictions",":","dict","A","dictionary","with","keys","{","``","spec","''",",","``","wav","''","}","with","predicted","features","."]
code: def compute_forward(self, batch, stage):
      """Apply masking to convert from noisy waveforms to enhanced signals.
  
      Arguments
      ---------
      batch : PaddedBatch
          This batch object contains all the relevant tensors for computation.
      stage : sb.Stage
          One of sb.Stage.TRAIN, sb.Stage.VALID, or sb.Stage.TEST.
  
      Returns
      -------
      predictions : dict
          A dictionary with keys {"spec", "wav"} with predicted features.
      """
  
      # We first move the batch to the appropriate device, and
      # compute the features necessary for masking.
      batch = batch.to(self.device)
      self.clean_wavs, self.lens = batch.clean_sig
  
      noisy_wavs, self.lens = self.hparams.wav_augment(
          self.clean_wavs, self.lens
      )
  
      noisy_feats = self.compute_feats(noisy_wavs)
  
      # Masking is done here with the "signal approximation (SA)" algorithm.
      # The masked input is compared directly with clean speech targets.
      mask = self.modules.model(noisy_feats)
      predict_spec = torch.mul(mask, noisy_feats)
  
      # Also return predicted wav, for evaluation. Note that this could
      # also be used for a time-domain loss term.
      predict_wav = self.hparams.resynth(
          torch.expm1(predict_spec), noisy_wavs
      )
  
      # Return a dictionary so we don't have to remember the order
      return {"spec": predict_spec, "wav": predict_wav}
  
file_path: speechbrain/templates/enhancement/train.py
imports: import sys
  import torch
  import speechbrain
  from hyperpyyaml import load_hyperpyyaml
  from mini_librispeech_prepare import prepare_mini_librispeech
label_desc: Use image node_id 1 for calling the SEBrain obj's underlying member method code with example usage: obj.compute_forward(batch, stage) and returns: dict