예제 #1
0
파일: rnnt.py 프로젝트: AlexGrinch/NeMo
    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
예제 #2
0
    def output_ports(self):
        """Returns definitions of module output ports.

        loss:
            NeuralType(None)
        """
        return {"loss": NeuralType(elements_type=LossType())}
예제 #3
0
파일: data_layer.py 프로젝트: antimora/NeMo
    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
예제 #4
0
 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
예제 #5
0
 def output_ports(self):
     return {
         "mod_out":
         NeuralType(
             (AxisType(AxisKind.Batch), AxisType(AxisKind.Dimension, 1)),
             ChannelType())
     }
예제 #6
0
파일: losses.py 프로젝트: zxh263/NeMo
    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
예제 #7
0
            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())}
예제 #8
0
 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()
         )
     }
예제 #9
0
    def output_ports(self):
        """Returns definitions of module output ports.

        predictions:
            NeuralType(None)
        """
        return {"predictions": NeuralType(None)}
예제 #10
0
 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()),
     }
예제 #11
0
    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)
예제 #12
0
 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),
     }
예제 #13
0
파일: losses.py 프로젝트: vsl9/NeMo
    def output_ports(self):
        """Returns definitions of module output ports.

        loss:
            NeuralType(None)
        """
        return {"loss": NeuralType(None)}
예제 #14
0
 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()),
     }
예제 #15
0
 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())
     }
예제 #16
0
    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)
예제 #17
0
 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()),
     }
예제 #18
0
    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
예제 #19
0
    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)
            }),
        }
예제 #20
0
 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
예제 #21
0
    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)})}
예제 #22
0
    def input_ports(self):
        """Return definitions of module input ports.

        Returns:
            Module input ports.
        """
        return {
            "encoding": NeuralType(('B', 'C', 'H', 'W'), ChannelType()),
        }
예제 #23
0
    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()),
            }
예제 #24
0
파일: misc.py 프로젝트: zxh263/NeMo
 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
예제 #25
0
    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()),
        }
예제 #26
0
    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
예제 #27
0
    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
예제 #28
0
파일: rnnt.py 프로젝트: mousebaiker/NeMo
    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),
            }
예제 #29
0
    def output_ports(self):
        """Return definitions of module output ports.

        Returns:
            Module output ports.
        """
        return {
            # Variant type
            'output_logit': NeuralType(('B', 'D'), LogitsType()),
        }
예제 #30
0
파일: jasper.py 프로젝트: vsl9/NeMo
    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)}),
        }