def create_and_check_xxx_model(self, config, input_ids, token_type_ids, input_mask, sequence_labels, token_labels, choice_labels): model = TFXxxModel(config=config) inputs = { 'input_ids': input_ids, 'attention_mask': input_mask, 'token_type_ids': token_type_ids } sequence_output, pooled_output = model(inputs) inputs = [input_ids, input_mask] sequence_output, pooled_output = model(inputs) sequence_output, pooled_output = model(input_ids) result = { "sequence_output": sequence_output.numpy(), "pooled_output": pooled_output.numpy(), } self.parent.assertListEqual( list(result["sequence_output"].shape), [self.batch_size, self.seq_length, self.hidden_size]) self.parent.assertListEqual(list(result["pooled_output"].shape), [self.batch_size, self.hidden_size])
def create_and_check_xxx_model(self, config, input_ids, token_type_ids, input_mask, sequence_labels, token_labels, choice_labels): model = TFXxxModel(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.assertListEqual( list(result["last_hidden_state"].shape), [self.batch_size, self.seq_length, self.hidden_size]) self.parent.assertListEqual(list(result["pooler_output"].shape), [self.batch_size, self.hidden_size])
def test_model_from_pretrained(self): for model_name in ['xxx-base-uncased']: model = TFXxxModel.from_pretrained(model_name, cache_dir=CACHE_DIR) self.assertIsNotNone(model)
def test_model_from_pretrained(self): cache_dir = "/tmp/transformers_test/" for model_name in ['xxx-base-uncased']: model = TFXxxModel.from_pretrained(model_name, cache_dir=cache_dir) shutil.rmtree(cache_dir) self.assertIsNotNone(model)