Definitive HeisenDistilBug fix

cc @julien-c @@thomwolf
This commit is contained in:
Lysandre 2020-01-27 12:09:58 -05:00
parent f09f42d4d3
commit 875c4ae48f
2 changed files with 5 additions and 1 deletions

View File

@ -112,8 +112,12 @@ class TFModelTesterMixin:
tfo = tf_model(inputs_dict, training=False)
tf_hidden_states = tfo[0].numpy()
pt_hidden_states = pto[0].numpy()
pt_hidden_states[np.isnan(tf_hidden_states)] = 0
tf_hidden_states[np.isnan(tf_hidden_states)] = 0
pt_hidden_states[np.isnan(pt_hidden_states)] = 0
tf_hidden_states[np.isnan(pt_hidden_states)] = 0
max_diff = np.amax(np.abs(tf_hidden_states - pt_hidden_states))
# Debug info (remove when fixed)
if max_diff >= 2e-2:

View File

@ -219,5 +219,5 @@ class TFDistilBertModelTest(TFModelTesterMixin, unittest.TestCase):
# @slow
# def test_model_from_pretrained(self):
# for model_name in list(DISTILBERT_PRETRAINED_MODEL_ARCHIVE_MAP.keys())[:1]:
# model = DistilBertModel.from_pretrained(model_name, cache_dir=CACHE_DIR)
# model = DistilBertModesss.from_pretrained(model_name, cache_dir=CACHE_DIR)
# self.assertIsNotNone(model)