Esempio n. 1
0
    def output_ports(self):
        """Returns definitions of module output ports.

        intent_logits:
            0: AxisType(BatchTag)

            1: AxisType(ChannelTag)

        slot_logits:
            0: AxisType(BatchTag)

            1: AxisType(TimeTag)

            2: AxisType(ChannelTag)
        """
        return {
            "intent_logits":
            NeuralType({
                0: AxisType(BatchTag),
                1: AxisType(ChannelTag)
            }),
            "slot_logits":
            NeuralType({
                0: AxisType(BatchTag),
                1: AxisType(TimeTag),
                2: AxisType(ChannelTag)
            }),
        }
Esempio n. 2
0
    def output_ports(self):
        """Returns definitions of module output ports.

        loss:
            NeuralType(None)

        start_logits:
            0: AxisType(BatchTag)

            1: AxisType(TimeTag)

        end_logits:
            0: AxisType(BatchTag)

            1: AxisType(TimeTag)
        """
        return {
            "loss":
            NeuralType(None),
            "start_logits":
            NeuralType({
                0: AxisType(BatchTag),
                1: AxisType(TimeTag)
            }),
            "end_logits":
            NeuralType({
                0: AxisType(BatchTag),
                1: AxisType(TimeTag)
            }),
        }
Esempio n. 3
0
 def output_ports(self):
     """Returns definitions of module output ports.
     """
     return {
         "punct_logits": NeuralType(('B', 'T', 'D'), LogitsType()),
         "capit_logits": NeuralType(('B', 'T', 'D'), LogitsType()),
     }
Esempio n. 4
0
    def test_multi_dl_wrong_combination(self):
        dataset_size_0 = 2
        dataset_size_1 = 2
        unknown_combination = "cross"
        batch_size = 4
        shuffle = False
        dl_1 = nemo.backends.pytorch.common.ZerosDataLayer(
            size=dataset_size_0,
            dtype=torch.FloatTensor,
            batch_size=batch_size,
            output_ports={
                "a": NeuralType(('B', 'T'), ChannelType()),
                "b": NeuralType(('B', 'T'), ChannelType())
            },
        )
        dl_2 = nemo.backends.pytorch.common.ZerosDataLayer(
            size=dataset_size_1,
            dtype=torch.FloatTensor,
            batch_size=batch_size,
            output_ports={
                "a": NeuralType(('B', 'T'), ChannelType()),
                "c": NeuralType(('B', 'T'), ChannelType())
            },
        )

        with pytest.raises(ValueError):
            data_layer = nemo.backends.pytorch.common.MultiDataLayer(
                data_layers=[dl_1, dl_2],
                batch_size=batch_size,
                shuffle=shuffle,
                combination_mode=unknown_combination)
Esempio n. 5
0
    def input_ports(self):
        """Returns definitions of module input ports.

        logits:
            0: AxisType(BatchTag)

            1: AxisType(TimeTag)

            2: AxisType(ChannelTag)

        labels:
            0: AxisType(BatchTag)

            1: AxisType(TimeTag)

        loss_mask:
            0: AxisType(BatchTag)

            1: AxisType(TimeTag)
        """
        return {
            "logits": NeuralType({0: AxisType(BatchTag), 1: AxisType(TimeTag), 2: AxisType(ChannelTag)}),
            "labels": NeuralType({0: AxisType(BatchTag), 1: AxisType(TimeTag)}),
            "loss_mask": NeuralType({0: AxisType(BatchTag), 1: AxisType(TimeTag)}),
        }
Esempio n. 6
0
    def test_multi_dl_zip_working(self):
        dataset_size_0 = 2
        dataset_size_1 = 2
        final_dataset_size = 2
        batch_size = 4
        shuffle = False
        dl_1 = nemo.backends.pytorch.common.ZerosDataLayer(
            size=dataset_size_0,
            dtype=torch.FloatTensor,
            batch_size=batch_size,
            output_ports={
                "a": NeuralType(('B', 'T'), ChannelType()),
                "b": NeuralType(('B', 'T'), ChannelType())
            },
        )
        dl_2 = nemo.backends.pytorch.common.ZerosDataLayer(
            size=dataset_size_1,
            dtype=torch.FloatTensor,
            batch_size=batch_size,
            output_ports={
                "a": NeuralType(('B', 'T'), ChannelType()),
                "c": NeuralType(('B', 'T'), ChannelType())
            },
        )

        data_layer = nemo.backends.pytorch.common.MultiDataLayer(
            data_layers=[dl_1, dl_2],
            batch_size=batch_size,
            shuffle=shuffle,
            combination_mode=DataCombination.ZIP)
        self.assertEqual(len(data_layer), final_dataset_size)
    def input_ports(self):
        """Returns definitions of module input ports.

        image1:
            0: AxisType(BatchTag)

            1: AxisType(ChannelTag)

            2: AxisType(HeightTag, 28)

            3: AxisType(WidthTag, 28)

        image2:
            0: AxisType(BatchTag)

            1: AxisType(ChannelTag)

            2: AxisType(HeightTag, 28)

            3: AxisType(WidthTag, 28)
        """
        return {
            "image1": NeuralType({
                0: AxisType(BatchTag),
                1: AxisType(ChannelTag),
                2: AxisType(HeightTag, 28),
                3: AxisType(WidthTag, 28)}),
            "image2": NeuralType({
                0: AxisType(BatchTag),
                1: AxisType(ChannelTag),
                2: AxisType(HeightTag, 28),
                3: AxisType(WidthTag, 28)})
        }
Esempio n. 8
0
    def output_ports(self):
        """Returns definitions of module output ports.

        input_ids: indices of tokens which constitute batches of text segments
            0: AxisType(BatchTag)

            1: AxisType(TimeTag)

        input_mask: bool tensor with 0s in place of tokens to be masked
            0: AxisType(BatchTag)

            1: AxisType(TimeTag)

        labels: indices of tokens which should be predicted from each of the
            corresponding tokens in input_ids; for left-to-right language
            modeling equals to input_ids shifted by 1 to the right
            0: AxisType(BatchTag)

            1: AxisType(TimeTag)
        """
        return {
            # "input_ids": NeuralType({0: AxisType(BatchTag), 1: AxisType(TimeTag)}),
            # "input_mask": NeuralType({0: AxisType(BatchTag), 1: AxisType(TimeTag)}),
            # "labels": NeuralType({0: AxisType(BatchTag), 1: AxisType(TimeTag)}),
            "input_ids": NeuralType(('B', 'T'), ChannelType()),
            "input_mask": NeuralType(('B', 'T'), ChannelType()),
            "labels": NeuralType(('B', 'T'), LabelsType()),
        }
Esempio n. 9
0
    def test_port_renaming(self):
        batch_size = 4
        dataset_size = 4
        shuffle = False
        dl_1 = nemo.backends.pytorch.common.ZerosDataLayer(
            size=dataset_size,
            dtype=torch.FloatTensor,
            batch_size=batch_size,
            output_ports={
                "a": NeuralType(('B', 'T'), ChannelType()),
                "b": NeuralType(('B', 'T'), ChannelType())
            },
        )
        dl_2 = nemo.backends.pytorch.common.ZerosDataLayer(
            size=dataset_size,
            dtype=torch.FloatTensor,
            batch_size=batch_size,
            output_ports={
                "a": NeuralType(('B', 'T'), ChannelType()),
                "b": NeuralType(('B', 'T'), ChannelType())
            },
        )

        data_layer = nemo.backends.pytorch.common.MultiDataLayer(
            data_layers=[dl_1, dl_2],
            batch_size=batch_size,
            shuffle=shuffle,
            combination_mode=DataCombination.CROSSPRODUCT,
            port_names=["1", "2", "3", "4"],
        )
        self.assertEqual([*data_layer.output_ports], ["1", "2", "3", "4"])
Esempio n. 10
0
    def output_ports(self):
        """Returns definitions of module output ports.

        input_ids:
            0: AxisType(BatchTag)

            1: AxisType(TimeTag)

        input_type_ids:
            0: AxisType(BatchTag)

            1: AxisType(TimeTag)

        input_mask:
            0: AxisType(BatchTag)

            1: AxisType(TimeTag)

        labels:
            0: AxisType(BatchTag)

        """
        return {
            "input_ids": NeuralType({0: AxisType(BatchTag), 1: AxisType(TimeTag)}),
            "input_type_ids": NeuralType({0: AxisType(BatchTag), 1: AxisType(TimeTag)}),
            "input_mask": NeuralType({0: AxisType(BatchTag), 1: AxisType(TimeTag)}),
            "labels": NeuralType({0: AxisType(BatchTag)}),
        }
Esempio n. 11
0
    def input_ports(self):
        """Returns definitions of module input ports.

        interpolated_image:
            0: AxisType(BatchTag)

            1: AxisType(ChannelTag)

            2: AxisType(HeightTag, 28)

            3: AxisType(WidthTag, 28)

        interpolated_decision:
            0: AxisType(BatchTag)

            1: AxisType(ChannelTag, 1)
        """
        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)
            }),
        }
Esempio n. 12
0
    def input_ports(self):
        """Returns definitions of module input ports.

        logits:
            0: AxisType(BatchTag)

            1: AxisType(TimeTag)

            2: AxisType(ChannelTag)

        target_ids:
            0: AxisType(BatchTag)

            1: AxisType(TimeTag)
        """
        return {
            "logits":
            NeuralType({
                0: AxisType(BatchTag),
                1: AxisType(TimeTag),
                2: AxisType(ChannelTag)
            }),
            "target_ids":
            NeuralType({
                0: AxisType(BatchTag),
                1: AxisType(TimeTag)
            }),
        }
Esempio n. 13
0
    def create_ports():
        input_ports = {
            "decision": NeuralType({0: AxisType(BatchTag),
                                    1: AxisType(ChannelTag, 1)}),
        }

        output_ports = {"loss": NeuralType(None)}
        return input_ports, output_ports
Esempio n. 14
0
 def input_ports(self):
     """Returns definitions of module input ports.
     """
     return {
         "logits": NeuralType(('B', 'T', 'D'), LogitsType()),
         "start_positions": NeuralType(tuple('B'), ChannelType()),
         "end_positions": NeuralType(tuple('B'), ChannelType()),
     }
 def input_ports(self):
     """Returns definitions of module input ports.
     """
     return {
         "logits": NeuralType(('B', 'T', 'D'), LogitsType()),
         "labels": NeuralType(('B', 'T'), LabelsType()),
         "output_mask": NeuralType(('B', 'T'), MaskType(), optional=True),
     }
Esempio n. 16
0
 def output_ports(self):
     """Returns definitions of module output ports.
     logits (float): First token of the BERT representation of the utterance followed by fc and dropout
     hidden_states (float) : BERT representation of the utterance with applied dropout
     """
     return {
         "logits": NeuralType(('B', 'T'), EmbeddedTextType()),
         "hidden_states": NeuralType(('B', 'T', 'C'), ChannelType()),
     }
Esempio n. 17
0
 def input_ports(self):
     """Returns definitions of module input ports.
     """
     return {
         # "logits": NeuralType({0: AxisType(BatchTag), 1: AxisType(TimeTag), 2: AxisType(ChannelTag)}),
         # "target_ids": NeuralType({0: AxisType(BatchTag), 1: AxisType(TimeTag)}),
         "logits": NeuralType(('B', 'T', 'D'), LogitsType()),
         "target_ids": NeuralType(('B', 'T'), LabelsType()),
     }
Esempio n. 18
0
 def input_ports(self):
     """Returns definitions of module input ports.
     """
     return {
         # "logits": NeuralType({0: AxisType(BatchTag), 1: AxisType(TimeTag), 2: AxisType(ChannelTag)}),
         # "start_positions": NeuralType({0: AxisType(BatchTag)}),
         # "end_positions": NeuralType({0: AxisType(BatchTag)}),
         "logits": NeuralType(('B', 'T', 'D'), LogitsType()),
         "start_positions": NeuralType(tuple('B'), ChannelType()),
         "end_positions": NeuralType(tuple('B'), ChannelType()),
     }
Esempio n. 19
0
 def create_ports():
     input_ports = {
         "image": NeuralType({0: AxisType(BatchTag),
                              1: AxisType(ChannelTag),
                              2: AxisType(HeightTag, 28),
                              3: AxisType(WidthTag, 28)})
     }
     output_ports = {
         "decision": NeuralType({0: AxisType(BatchTag),
                                 1: AxisType(ChannelTag, 1)})
     }
     return input_ports, output_ports
    def output_ports(self):
        """Returns definitions of module output ports.

        intent_logits:
            TODO
        slot_logits:
            TODO
        """
        return {
            "intent_logits": NeuralType(('B', 'D'), LogitsType()),
            "slot_logits": NeuralType(('B', 'T', 'D'), LogitsType()),
        }
Esempio n. 21
0
    def create_ports():
        input_ports = {
            "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)}),
        }

        output_ports = {"loss": NeuralType(None)}
        return input_ports, output_ports
Esempio n. 22
0
 def output_ports(self):
     """Returns definitions of module output ports.
     """
     return {
         # "input_ids": NeuralType({0: AxisType(BatchTag), 1: AxisType(TimeTag)}),
         # "input_type_ids": NeuralType({0: AxisType(BatchTag), 1: AxisType(TimeTag)}),
         # "input_mask": NeuralType({0: AxisType(BatchTag), 1: AxisType(TimeTag)}),
         # "labels": NeuralType({0: AxisType(BatchTag)}),
         "input_ids": NeuralType(('B', 'T'), ChannelType()),
         "input_type_ids": NeuralType(('B', 'T'), ChannelType()),
         "input_mask": NeuralType(('B', 'T'), ChannelType()),
         "labels": NeuralType(tuple('B'), LabelsType()),
     }
Esempio n. 23
0
 def create_ports(input_size=(32, 32)):
     input_ports = {}
     output_ports = {
         "latent": NeuralType({0: AxisType(BatchTag),
                               1: AxisType(ChannelTag, 64),
                               2: AxisType(HeightTag, 4),
                               3: AxisType(WidthTag, 4)}),
         "image": NeuralType({0: AxisType(BatchTag),
                              1: AxisType(ChannelTag),
                              2: AxisType(HeightTag, input_size[1]),
                              3: AxisType(WidthTag, input_size[0])}),
         "label": NeuralType({0: AxisType(BatchTag)})
     }
     return input_ports, output_ports
Esempio n. 24
0
    def output_ports(self):
        """Returns definitions of module output ports.

        loss:
            NeuralType(None)
        """
        return {"loss": NeuralType(None)}
    def input_ports(self):
        """Returns definitions of module input ports.

        hidden_states:
            TODO
        """
        return {"hidden_states": NeuralType(('B', 'T', 'C'), ChannelType())}
 def output_ports(self):
     """Returns definitions of module output ports.
     input_ids:
         indices of tokens which constitute batches of masked text segments
     input_type_ids:
         tensor with 0's and 1's to denote the text segment type
     input_mask:
         bool tensor with 0s in place of tokens to be masked
     labels: sequence classification id
     """
     return {
         "input_ids": NeuralType(('B', 'T'), ChannelType()),
         "input_type_ids": NeuralType(('B', 'T'), ChannelType()),
         "input_mask": NeuralType(('B', 'T'), ChannelType()),
         "labels": NeuralType(tuple('B'), LabelsType()),
     }
Esempio n. 27
0
    def output_ports(self):
        """Returns definitions of module output ports.

        preds:
            0: AxisType(RegressionTag)
        """
        return {"preds": NeuralType({0: AxisType(RegressionTag)})}
Esempio n. 28
0
    def output_ports(self):
        """Returns definitions of module output ports.

        loss:
            NeuralType(None)
        """
        return {"loss": NeuralType(elements_type=LossType())}
Esempio n. 29
0
    def input_ports(self):
        """Returns definitions of module input ports.

        """
        return {
            # "intent_logits": NeuralType({0: AxisType(BatchTag), 1: AxisType(ChannelTag)}),
            # "slot_logits": NeuralType({0: AxisType(BatchTag), 1: AxisType(TimeTag), 2: AxisType(ChannelTag)}),
            # "loss_mask": NeuralType({0: AxisType(BatchTag), 1: AxisType(TimeTag)}),
            # "intents": NeuralType({0: AxisType(BatchTag)}),
            # "slots": NeuralType({0: AxisType(BatchTag), 1: AxisType(TimeTag)}),
            "intent_logits": NeuralType(('B', 'D'), LogitsType()),
            "slot_logits": NeuralType(('B', 'T', 'D'), LogitsType()),
            "loss_mask": NeuralType(('B', 'T'), ChannelType()),
            "intents": NeuralType(tuple('B'), ChannelType()),
            "slots": NeuralType(('B', 'T'), ChannelType()),
        }
Esempio n. 30
0
    def output_ports(self):
        """Returns definitions of module output ports.

        input_ids:
            indices of tokens which constitute batches of text segments
        input_type_ids:
            tensor with 0's and 1's to denote the text segment type
        input_mask:
            bool tensor with 0s in place of tokens to be masked
        loss_mask:
            used to mask and ignore tokens in the loss function
        subtokens_mask:
            used to ignore the outputs of unwanted tokens in
            the inference and evaluation like the start and end tokens
        intents:
            intents labels
        slots:
            slots labels
        """
        return {
            "input_ids": NeuralType(('B', 'T'), ChannelType()),
            "input_type_ids": NeuralType(('B', 'T'), ChannelType()),
            "input_mask": NeuralType(('B', 'T'), ChannelType()),
            "loss_mask": NeuralType(('B', 'T'), MaskType()),
            "subtokens_mask": NeuralType(('B', 'T'), ChannelType()),
            "intents": NeuralType(tuple('B'), LabelsType()),
            "slots": NeuralType(('B', 'T'), LabelsType()),
        }