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) }), }
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) }), }
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()), }
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)
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)}), }
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)}) }
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()), }
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"])
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)}), }
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) }), }
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) }), }
def create_ports(): input_ports = { "decision": NeuralType({0: AxisType(BatchTag), 1: AxisType(ChannelTag, 1)}), } output_ports = {"loss": NeuralType(None)} return input_ports, output_ports
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), }
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()), }
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()), }
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()), }
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()), }
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
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()), }
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
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()), }
def output_ports(self): """Returns definitions of module output ports. preds: 0: AxisType(RegressionTag) """ return {"preds": NeuralType({0: AxisType(RegressionTag)})}
def output_ports(self): """Returns definitions of module output ports. loss: NeuralType(None) """ return {"loss": NeuralType(elements_type=LossType())}
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()), }
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()), }