Ejemplo n.º 1
0
        def create_and_check_t5_model(self, config, input_ids, input_mask,
                                      token_labels):
            model = TFT5Model(config=config)
            inputs = {
                "input_ids": input_ids,
                "decoder_input_ids": input_ids,
                "decoder_attention_mask": input_mask,
            }
            encoder_output, decoder_output = model(inputs)

            encoder_output, decoder_output = model(
                input_ids,
                decoder_attention_mask=input_mask,
                input_ids=input_ids)

            result = {
                "encoder_output": encoder_output.numpy(),
                "decoder_output": decoder_output.numpy(),
            }
            self.parent.assertListEqual(
                list(result["encoder_output"].shape),
                [self.batch_size, self.seq_length, self.hidden_size])
            self.parent.assertListEqual(
                list(result["decoder_output"].shape),
                [self.batch_size, self.seq_length, self.hidden_size])
Ejemplo n.º 2
0
 def test_model_from_pretrained(self):
     for model_name in ["t5-small"]:
         model = TFT5Model.from_pretrained(model_name, cache_dir=CACHE_DIR)
         self.assertIsNotNone(model)
Ejemplo n.º 3
0
 def test_model_from_pretrained(self):
     cache_dir = "/tmp/transformers_test/"
     for model_name in ['t5-small']:
         model = TFT5Model.from_pretrained(model_name, cache_dir=cache_dir)
         shutil.rmtree(cache_dir)
         self.assertIsNotNone(model)