Ejemplo n.º 1
0
        def create_and_check_electra_model(
            self, config, input_ids, token_type_ids, input_mask, sequence_labels, token_labels, choice_labels
        ):
            model = TFElectraModel(config=config)
            inputs = {"input_ids": input_ids, "attention_mask": input_mask, "token_type_ids": token_type_ids}
            (sequence_output,) = model(inputs)

            inputs = [input_ids, input_mask]
            (sequence_output,) = model(inputs)

            (sequence_output,) = model(input_ids)

            result = {
                "sequence_output": sequence_output.numpy(),
            }
            self.parent.assertListEqual(
                list(result["sequence_output"].shape), [self.batch_size, self.seq_length, self.hidden_size]
            )
Ejemplo n.º 2
0
    def create_and_check_electra_model(self, config, input_ids, token_type_ids,
                                       input_mask, sequence_labels,
                                       token_labels, choice_labels):
        model = TFElectraModel(config=config)
        inputs = {
            "input_ids": input_ids,
            "attention_mask": input_mask,
            "token_type_ids": token_type_ids
        }
        result = model(inputs)

        inputs = [input_ids, input_mask]
        result = model(inputs)

        result = model(input_ids)

        self.parent.assertEqual(
            result.last_hidden_state.shape,
            (self.batch_size, self.seq_length, self.hidden_size))
Ejemplo n.º 3
0
 def test_model_from_pretrained(self):
     # for model_name in TF_ELECTRA_PRETRAINED_MODEL_ARCHIVE_LIST[:1]:
     for model_name in ["google/electra-small-discriminator"]:
         model = TFElectraModel.from_pretrained(model_name)
         self.assertIsNotNone(model)
 def test_model_from_pretrained(self):
     # for model_name in list(TF_ELECTRA_PRETRAINED_MODEL_ARCHIVE_MAP.keys())[:1]:
     for model_name in ["electra-small-discriminator"]:
         model = TFElectraModel.from_pretrained(model_name,
                                                cache_dir=CACHE_DIR)
         self.assertIsNotNone(model)