Remove tolerance + drop_rows_to_fit by default (#9507)
* Remove tolerance + drop_rows_to_fit by default * remove drop_rows_to_fit
This commit is contained in:
@@ -540,9 +540,6 @@ def prepare_tapas_batch_inputs_for_training():
|
||||
return table, queries, answer_coordinates, answer_text, float_answer
|
||||
|
||||
|
||||
TOLERANCE = 1
|
||||
|
||||
|
||||
@require_torch
|
||||
@require_scatter
|
||||
class TapasModelIntegrationTest(unittest.TestCase):
|
||||
@@ -574,12 +571,12 @@ class TapasModelIntegrationTest(unittest.TestCase):
|
||||
device=torch_device,
|
||||
)
|
||||
|
||||
self.assertTrue(torch.allclose(outputs.last_hidden_state[:, :3, :3], expected_slice, atol=TOLERANCE))
|
||||
self.assertTrue(torch.allclose(outputs.last_hidden_state[:, :3, :3], expected_slice, atol=0.0005))
|
||||
|
||||
# test the pooled output
|
||||
expected_slice = torch.tensor([[0.987518311, -0.970520139, -0.994303405]], device=torch_device)
|
||||
|
||||
self.assertTrue(torch.allclose(outputs.pooler_output[:, :3], expected_slice, atol=TOLERANCE))
|
||||
self.assertTrue(torch.allclose(outputs.pooler_output[:, :3], expected_slice, atol=0.0005))
|
||||
|
||||
@unittest.skip(reason="Model not available yet")
|
||||
def test_inference_masked_lm(self):
|
||||
@@ -634,7 +631,7 @@ class TapasModelIntegrationTest(unittest.TestCase):
|
||||
device=torch_device,
|
||||
)
|
||||
|
||||
self.assertTrue(torch.allclose(logits, expected_tensor, atol=TOLERANCE))
|
||||
self.assertTrue(torch.allclose(logits, expected_tensor, atol=0.015))
|
||||
|
||||
@slow
|
||||
def test_inference_question_answering_head_conversational_absolute_embeddings(self):
|
||||
@@ -683,7 +680,7 @@ class TapasModelIntegrationTest(unittest.TestCase):
|
||||
device=torch_device,
|
||||
)
|
||||
|
||||
self.assertTrue(torch.allclose(logits, expected_tensor, atol=TOLERANCE))
|
||||
self.assertTrue(torch.allclose(logits, expected_tensor, atol=0.01))
|
||||
|
||||
@slow
|
||||
def test_inference_question_answering_head_weak_supervision(self):
|
||||
@@ -710,7 +707,7 @@ class TapasModelIntegrationTest(unittest.TestCase):
|
||||
device=torch_device,
|
||||
)
|
||||
|
||||
self.assertTrue(torch.allclose(logits[:, -6:], expected_slice, atol=TOLERANCE))
|
||||
self.assertTrue(torch.allclose(logits[:, -6:], expected_slice, atol=0.4))
|
||||
|
||||
# test the aggregation logits
|
||||
logits_aggregation = outputs.logits_aggregation
|
||||
@@ -721,7 +718,7 @@ class TapasModelIntegrationTest(unittest.TestCase):
|
||||
device=torch_device,
|
||||
)
|
||||
|
||||
self.assertTrue(torch.allclose(logits_aggregation, expected_tensor, atol=TOLERANCE))
|
||||
self.assertTrue(torch.allclose(logits_aggregation, expected_tensor, atol=0.001))
|
||||
|
||||
# test the predicted answer coordinates and aggregation indices
|
||||
EXPECTED_PREDICTED_ANSWER_COORDINATES = [[(0, 0)], [(1, 2)]]
|
||||
@@ -778,7 +775,7 @@ class TapasModelIntegrationTest(unittest.TestCase):
|
||||
# test the loss
|
||||
loss = outputs.loss
|
||||
expected_loss = torch.tensor(3.3527612686157227e-08, device=torch_device)
|
||||
self.assertTrue(torch.allclose(loss, expected_loss, atol=TOLERANCE))
|
||||
self.assertTrue(torch.allclose(loss, expected_loss, atol=1e-6))
|
||||
|
||||
# test the logits on the first example
|
||||
logits = outputs.logits
|
||||
@@ -799,7 +796,7 @@ class TapasModelIntegrationTest(unittest.TestCase):
|
||||
device=torch_device,
|
||||
)
|
||||
|
||||
self.assertTrue(torch.allclose(logits[0, -9:], expected_slice, atol=TOLERANCE))
|
||||
self.assertTrue(torch.allclose(logits[0, -9:], expected_slice, atol=1e-6))
|
||||
|
||||
# test the aggregation logits on the second example
|
||||
logits_aggregation = outputs.logits_aggregation
|
||||
@@ -807,7 +804,7 @@ class TapasModelIntegrationTest(unittest.TestCase):
|
||||
self.assertEqual(logits_aggregation.shape, expected_shape)
|
||||
expected_slice = torch.tensor([-4.0538, 40.0304, -5.3554, 23.3965], device=torch_device)
|
||||
|
||||
self.assertTrue(torch.allclose(logits_aggregation[1, -4:], expected_slice, atol=TOLERANCE))
|
||||
self.assertTrue(torch.allclose(logits_aggregation[1, -4:], expected_slice, atol=1e-4))
|
||||
|
||||
@slow
|
||||
def test_inference_question_answering_head_strong_supervision(self):
|
||||
@@ -854,7 +851,7 @@ class TapasModelIntegrationTest(unittest.TestCase):
|
||||
device=torch_device,
|
||||
)
|
||||
|
||||
self.assertTrue(torch.allclose(logits, expected_tensor, atol=TOLERANCE))
|
||||
self.assertTrue(torch.allclose(logits, expected_tensor, atol=0.02))
|
||||
|
||||
# test the aggregation logits
|
||||
logits_aggregation = outputs.logits_aggregation
|
||||
@@ -864,7 +861,7 @@ class TapasModelIntegrationTest(unittest.TestCase):
|
||||
[[16.5659733, -3.06624889, -2.34152961, -0.970244825]], device=torch_device
|
||||
) # PyTorch model outputs [[16.5679, -3.0668, -2.3442, -0.9674]]
|
||||
|
||||
self.assertTrue(torch.allclose(logits_aggregation, expected_tensor, atol=TOLERANCE))
|
||||
self.assertTrue(torch.allclose(logits_aggregation, expected_tensor, atol=0.003))
|
||||
|
||||
@slow
|
||||
def test_inference_classification_head(self):
|
||||
@@ -885,7 +882,7 @@ class TapasModelIntegrationTest(unittest.TestCase):
|
||||
[[0.795137286, 9.5572]], device=torch_device
|
||||
) # Note that the PyTorch model outputs [[0.8057, 9.5281]]
|
||||
|
||||
self.assertTrue(torch.allclose(outputs.logits, expected_tensor, atol=TOLERANCE))
|
||||
self.assertTrue(torch.allclose(outputs.logits, expected_tensor, atol=0.05))
|
||||
|
||||
|
||||
# Below: tests for Tapas utilities which are defined in modeling_tapas.py.
|
||||
|
||||
@@ -290,7 +290,7 @@ class TapasTokenizationTest(TokenizerTesterMixin, unittest.TestCase):
|
||||
|
||||
@slow
|
||||
def test_sequence_builders(self):
|
||||
tokenizer = self.tokenizer_class.from_pretrained("nielsr/tapas-base-finetuned-wtq")
|
||||
tokenizer = self.tokenizer_class.from_pretrained("google/tapas-base-finetuned-wtq")
|
||||
|
||||
empty_table = self.get_table(tokenizer, length=0)
|
||||
table = self.get_table(tokenizer, length=10)
|
||||
|
||||
Reference in New Issue
Block a user