def input_types(self): state_type = NeuralType(('D', 'B', 'D'), ElementType()) mytypes = { 'encoder_outputs': NeuralType(('B', 'D', 'T'), AcousticEncodedRepresentation()), "targets": NeuralType(('B', 'T'), LabelsType()), "target_length": NeuralType(tuple('B'), LengthsType()), 'input-states-1': state_type, 'input-states-2': state_type, } return mytypes
def output_ports(self): """Returns definitions of module output ports. loss: NeuralType(None) """ return {"loss": NeuralType(elements_type=LossType())}
def create_ports(): input_ports = { "input_signal": NeuralType({0: AxisType(BatchTag), 1: AxisType(TimeTag)}), "length": NeuralType({0: AxisType(BatchTag)}), } output_ports = { "processed_signal": NeuralType({0: AxisType(BatchTag), 1: AxisType(SpectrogramSignalTag), 2: AxisType(ProcessedTimeTag)}), "processed_length": NeuralType({0: AxisType(BatchTag)}) } return input_ports, output_ports
def create_ports(): input_ports = { 'log_probs': NeuralType({ 0: AxisType(BatchTag), 1: AxisType(TimeTag), 2: AxisType(ChannelTag) }), 'targets': NeuralType({ 0: AxisType(BatchTag), 1: AxisType(TimeTag) }) } output_ports = {'loss': NeuralType(None)} return input_ports, output_ports
def output_ports(self): return { "mod_out": NeuralType( (AxisType(AxisKind.Batch), AxisType(AxisKind.Dimension, 1)), ChannelType()) }
def create_ports(): input_ports = { "log_probs": NeuralType({1: AxisType(TimeTag), 0: AxisType(BatchTag), 2: AxisType(ChannelTag)}), "targets": NeuralType({0: AxisType(BatchTag), 1: AxisType(TimeTag)}), "input_length": NeuralType({0: AxisType(BatchTag)}), "target_length": NeuralType({0: AxisType(BatchTag)}) } output_ports = {"loss": NeuralType(None)} return input_ports, output_ports
def output_ports(self): """Returns definitions of module output ports. Returns: A (dict) of module's output ports names to NeuralTypes mapping """ return {"y_pred": NeuralType(('B', 'D'), ChannelType())}
def output_ports(self): """ Returns definitions of module output ports. """ return { "predictions": NeuralType( axes=(AxisType(kind=AxisKind.Batch), AxisType(kind=AxisKind.Dimension)), elements_type=LogprobsType() ) }
def output_ports(self): """Returns definitions of module output ports. predictions: NeuralType(None) """ return {"predictions": NeuralType(None)}
def output_types(self) -> Optional[Dict[str, NeuralType]]: """Returns definitions of module output ports. """ return { 'input_ids': NeuralType(('B', 'T'), ChannelType()), 'segment_ids': NeuralType(('B', 'T'), ChannelType()), 'input_mask': NeuralType(('B', 'T'), MaskType()), "labels": NeuralType( tuple('B'), RegressionValuesType() if self.task_name == 'sts-b' else CategoricalValuesType()), }
def test_infer_caching(self): data_source = nemo.backends.pytorch.common.ZerosDataLayer( size=1, dtype=torch.FloatTensor, batch_size=1, output_ports={ "dl_out": NeuralType((AxisType( AxisKind.Batch), AxisType(AxisKind.Dimension, 1)), ChannelType()) }, ) addten = AddsTen() minusten = SubtractsTen() zero_tensor = data_source() ten_tensor = addten(mod_in=zero_tensor) twenty_tensor = addten(mod_in=ten_tensor) thirty_tensor = addten(mod_in=twenty_tensor) evaluated_tensors = self.nf.infer( tensors=[twenty_tensor, thirty_tensor], verbose=False, cache=True) self.assertEqual(evaluated_tensors[0][0].squeeze().data, 20) self.assertEqual(evaluated_tensors[1][0].squeeze().data, 30) new_ten_tensor = minusten(mod_in=twenty_tensor) evaluated_tensors = self.nf.infer(tensors=[new_ten_tensor], verbose=False, use_cache=True) self.assertEqual(evaluated_tensors[0][0].squeeze().data, 10)
def input_types(self) -> Optional[Dict[str, NeuralType]]: if hasattr(self.preprocessor, '_sample_rate'): input_signal_eltype = AudioSignal( freq=self.preprocessor._sample_rate) else: input_signal_eltype = AudioSignal() return { "input_signal": NeuralType(('B', 'T'), input_signal_eltype, optional=True), "input_signal_length": NeuralType(tuple('B'), LengthsType(), optional=True), "processed_signal": NeuralType(('B', 'D', 'T'), SpectrogramType(), optional=True), "processed_signal_length": NeuralType(tuple('B'), LengthsType(), optional=True), }
def output_ports(self): """Returns definitions of module output ports. loss: NeuralType(None) """ return {"loss": NeuralType(None)}
def output_types(self) -> Optional[Dict[str, NeuralType]]: """Returns definitions of module output ports. """ return { 'audio_signal': NeuralType( ('B', 'T'), AudioSignal(freq=self._sample_rate) if self is not None and hasattr(self, '_sample_rate') else AudioSignal(), ), 'a_sig_length': NeuralType(tuple('B'), LengthsType()), 'label': NeuralType(tuple('B'), LabelsType()), 'label_length': NeuralType(tuple('B'), LengthsType()), }
def output_ports(self): # return {"mod_out": NeuralType({0: AxisType(BatchTag), 1: AxisType(BaseTag, dim=1)})} return { "mod_out": NeuralType( (AxisType(AxisKind.Batch), AxisType(AxisKind.Dimension, 1)), ChannelType()) }
def test_parameterized_type_audio_sampling_frequency(self): audio16K = NeuralType(axes=('B', 'T'), elements_type=AudioSignal(16000)) audio8K = NeuralType(axes=('B', 'T'), elements_type=AudioSignal(8000)) another16K = NeuralType(axes=('B', 'T'), elements_type=AudioSignal(16000)) self.assertEqual( audio8K.compare(audio16K), NeuralTypeComparisonResult.SAME_TYPE_INCOMPATIBLE_PARAMS) self.assertEqual( audio16K.compare(audio8K), NeuralTypeComparisonResult.SAME_TYPE_INCOMPATIBLE_PARAMS) self.assertEqual(another16K.compare(audio16K), NeuralTypeComparisonResult.SAME) self.assertEqual(audio16K.compare(another16K), NeuralTypeComparisonResult.SAME)
def input_ports(self): """Returns definitions of module input ports. """ return { # "interpolated_image": NeuralType( # { # 0: AxisType(BatchTag), # 1: AxisType(ChannelTag), # 2: AxisType(HeightTag, 28), # 3: AxisType(WidthTag, 28), # } # ), # "interpolated_decision": NeuralType({0: AxisType(BatchTag), 1: AxisType(ChannelTag, 1)}), "interpolated_image": NeuralType(('B', 'C', 'H', 'W'), ChannelType()), "interpolated_decision": NeuralType(('B', 'C'), ChannelType()), }
def test_void(self): btc_spctr = NeuralType(('B', 'T', 'C'), SpectrogramType()) btc_spct_bad = NeuralType(('B', 'T'), SpectrogramType()) btc_void = NeuralType(('B', 'T', 'C'), VoidType()) assert btc_void.compare(btc_spctr) == NeuralTypeComparisonResult.SAME assert btc_spctr.compare( btc_void) == NeuralTypeComparisonResult.INCOMPATIBLE assert btc_void.compare( btc_spct_bad) == NeuralTypeComparisonResult.INCOMPATIBLE
def input_ports(self): """Returns definitions of module input ports. logits: 4d tensor of logits 0: AxisType(BatchTag) 1: AxisType(TimeTag) 2: AxisType(ChannelTag) 3: AxisType(ChannelTag) targets: 3d tensor of labels 0: AxisType(BatchTag) 1: AxisType(ChannelTag) 2: AxisType(TimeTag) loss_mask: specifies the words to be considered in the loss calculation 0: AxisType(BatchTag) 1: AxisType(ChannelTag) """ return { "logits": NeuralType({ 0: AxisType(BatchTag), 1: AxisType(TimeTag), 2: AxisType(ChannelTag), 3: AxisType(ChannelTag) }), "targets": NeuralType({ 0: AxisType(BatchTag), 1: AxisType(ChannelTag), 2: AxisType(TimeTag) }), "loss_mask": NeuralType({ 0: AxisType(BatchTag), 1: AxisType(ChannelTag) }), }
def create_ports(): input_ports = { "encoder_output": NeuralType({ 0: AxisType(BatchTag), 1: AxisType(EncodedRepresentationTag), 2: AxisType(ProcessedTimeTag) }) } output_ports = { "output": NeuralType({ 0: AxisType(BatchTag), 1: AxisType(TimeTag), 2: AxisType(ChannelTag) }) } return input_ports, output_ports
def output_ports(self): """Returns definitions of module output ports. predictions: 0: AxisType(BatchTag) 1: AxisType(TimeTag) """ return {"predictions": NeuralType({0: AxisType(BatchTag), 1: AxisType(TimeTag)})}
def input_ports(self): """Return definitions of module input ports. Returns: Module input ports. """ return { "encoding": NeuralType(('B', 'C', 'H', 'W'), ChannelType()), }
def output_ports(self): """Returns definitions of module output ports. Returns: NeMo output port. """ if self.data_loader_type == HDFPileupDataLoader.Type.TEST: return { "encoding": NeuralType(('B', 'C', 'H', 'W'), ReadPileupNeuralType()), } else: return { "label": NeuralType(tuple('B'), VariantZygosityNeuralType()), "encoding": NeuralType(('B', 'C', 'H', 'W'), ReadPileupNeuralType()), }
def create_ports(): input_ports = { 'tensor': NeuralType({ 0: AxisType(BatchTag), 1: AxisType(ChannelTag), 2: AxisType(TimeTag) }) } output_ports = { 'tensor': NeuralType({ 0: AxisType(BatchTag), 1: AxisType(TimeTag), 2: AxisType(ChannelTag) }) } return input_ports, output_ports
def output_ports(self): """Returns definitions of module output ports. point_outputs: outputs of the generator gate_outputs: outputs of gating heads """ # return { # 'point_outputs': NeuralType( # {0: AxisType(BatchTag), 1: AxisType(TimeTag), 2: AxisType(ChannelTag), 3: AxisType(ChannelTag)} # ), # 'gate_outputs': NeuralType({0: AxisType(BatchTag), 1: AxisType(ChannelTag), 2: AxisType(ChannelTag)}), # } return { 'point_outputs': NeuralType(('B', 'T', 'D', 'D'), LogitsType()), 'gate_outputs': NeuralType(('B', 'D', 'D'), LogitsType()), }
def input_types(self): """Returns definitions of module input ports. """ input_types = {} for i in range(self._num_losses): input_types["loss_" + str(i + 1)] = NeuralType(elements_type=LossType()) return input_types
def create_ports(): input_ports = { "log_probs": NeuralType({ 0: AxisType(BatchTag), 1: AxisType(TimeTag), 2: AxisType(ChannelTag) }) } output_ports = { "predictions": NeuralType({ 0: AxisType(BatchTag), 1: AxisType(TimeTag) }) } return input_ports, output_ports
def output_types(self): """Returns definitions of module output ports. """ if not self._fuse_loss_wer: return { "outputs": NeuralType(('B', 'T', 'T', 'D'), LogprobsType()), } else: return { "loss": NeuralType(elements_type=LossType(), optional=True), "wer": NeuralType(elements_type=ElementType(), optional=True), "wer_numer": NeuralType(elements_type=ElementType(), optional=True), "wer_denom": NeuralType(elements_type=ElementType(), optional=True), }
def output_ports(self): """Return definitions of module output ports. Returns: Module output ports. """ return { # Variant type 'output_logit': NeuralType(('B', 'D'), LogitsType()), }
def input_ports(self): """Returns definitions of module input ports. audio_signal: 0: AxisType(BatchTag) 1: AxisType(SpectrogramSignalTag) 2: AxisType(ProcessedTimeTag) length: 0: AxisType(BatchTag) """ return { "audio_signal": NeuralType( {0: AxisType(BatchTag), 1: AxisType(SpectrogramSignalTag), 2: AxisType(ProcessedTimeTag),} ), "length": NeuralType({0: AxisType(BatchTag)}), }