def __init__( self, vocab, beam_width, alpha, beta, lm_path, num_cpus, cutoff_prob=1.0, cutoff_top_n=40, input_tensor=True ): try: from ctc_decoders import Scorer from ctc_decoders import ctc_beam_search_decoder_batch except ModuleNotFoundError: raise ModuleNotFoundError( "BeamSearchDecoderWithLM requires the " "installation of ctc_decoders " "from nemo/scripts/install_decoders.py" ) super().__init__() # Override the default placement from neural factory and set placement/device to be CPU. self._placement = DeviceType.CPU self._device = get_cuda_device(self._placement) if self._factory.world_size > 1: raise ValueError("BeamSearchDecoderWithLM does not run in distributed mode") self.scorer = Scorer(alpha, beta, model_path=lm_path, vocabulary=vocab) self.beam_search_func = ctc_beam_search_decoder_batch self.vocab = vocab self.beam_width = beam_width self.num_cpus = num_cpus self.cutoff_prob = cutoff_prob self.cutoff_top_n = cutoff_top_n self.input_tensor = input_tensor
def __init__(self, name=None): NeuralModule.__init__(self, name) # For NeuralModule API # Set module type. self._type = ModuleType.loss self._device = get_cuda_device(self.placement)
def __init__(self, pretrained_model_name=None, name=None): NeuralModule.__init__(self, name) # For NeuralModule API nn.Module.__init__(self) # For PyTorch API self._device = get_cuda_device(self.placement) # Store pretrained model name (to be removed/changed) self._pretrained_model_name = pretrained_model_name
def __init__(self, pretrained_model_name=None, name=None): # Initialize nn.Module first - important for the inspect during the init_params collection. nn.Module.__init__(self) # For PyTorch API NeuralModule.__init__(self, name) # For NeuralModule API # Set module type. self._type = ModuleType.trainable self._device = get_cuda_device(self.placement) # Store pretrained model name (to be removed/changed) self._pretrained_model_name = pretrained_model_name
def __init__(self): NeuralModule.__init__(self) # For NeuralModule API self._device = get_cuda_device(self.placement) # if 'batch_size' not in kwargs: # logging.warning("No batch_size specified in the data layer. " # "Setting batch_size to 1.") # kwargs['batch_size'] = 1 # Set default values of variables used by trained/passed to DataLoader. # NOTE: That also means that those are parameters of DataLoader/trainer, not DataLayer. # Thus those fields will be removed from DataLayer and moved to trainer configuration # (when the time for that will come;)) self._batch_size = 1 self._num_workers = os.cpu_count() # Use all CPUs by default. self._shuffle = False # Don't shuffle by default.
def __init__(self): NeuralModule.__init__(self) # For NeuralModule API self._device = get_cuda_device(self.placement)