Exemplo n.º 1
0
 def test_model_from_pretrained(self):
     cache_dir = "/tmp/transformers_test/"
     for model_name in list(
             TF_CTRL_PRETRAINED_MODEL_ARCHIVE_MAP.keys())[:1]:
         model = TFCTRLModel.from_pretrained(model_name,
                                             cache_dir=cache_dir)
         shutil.rmtree(cache_dir)
         self.assertIsNotNone(model)
    def create_and_check_ctrl_model(self, config, input_ids, input_mask, head_mask, token_type_ids, *args):
        model = TFCTRLModel(config=config)
        inputs = {"input_ids": input_ids, "attention_mask": input_mask, "token_type_ids": token_type_ids}
        result = model(inputs)

        inputs = [input_ids, None, input_mask]  # None is the input for 'past'
        result = model(inputs)

        result = model(input_ids)

        self.parent.assertListEqual(
            list(result["last_hidden_state"].shape), [self.batch_size, self.seq_length, self.hidden_size]
        )
Exemplo n.º 3
0
        def create_and_check_ctrl_model(self, config, input_ids, input_mask, head_mask, token_type_ids, *args):
            model = TFCTRLModel(config=config)
            inputs = {"input_ids": input_ids, "attention_mask": input_mask, "token_type_ids": token_type_ids}
            sequence_output = model(inputs)[0]

            inputs = [input_ids, None, input_mask]  # None is the input for 'past'
            sequence_output = model(inputs)[0]

            sequence_output = model(input_ids)[0]

            result = {
                "sequence_output": sequence_output.numpy(),
            }
            self.parent.assertListEqual(
                list(result["sequence_output"].shape), [self.batch_size, self.seq_length, self.hidden_size]
            )
Exemplo n.º 4
0
 def test_model_from_pretrained(self):
     for model_name in TF_CTRL_PRETRAINED_MODEL_ARCHIVE_LIST[:1]:
         model = TFCTRLModel.from_pretrained(model_name)
         self.assertIsNotNone(model)
Exemplo n.º 5
0
 def test_model_from_pretrained(self):
     for model_name in list(TF_CTRL_PRETRAINED_MODEL_ARCHIVE_MAP.keys())[:1]:
         model = TFCTRLModel.from_pretrained(model_name, cache_dir=CACHE_DIR)
         self.assertIsNotNone(model)