Replace build() with build_in_name_scope() for some TF tests (#28046)

Replace build() with build_in_name_scope() for some tests
This commit is contained in:
Matt
2023-12-14 17:42:25 +00:00
committed by GitHub
parent 050e0b44f6
commit 3060899be5
4 changed files with 10 additions and 10 deletions

View File

@@ -402,8 +402,8 @@ class TFModelUtilsTest(unittest.TestCase):
# Finally, check the model can be reloaded
new_model = TFBertModel.from_pretrained(tmp_dir)
model.build()
new_model.build()
model.build_in_name_scope()
new_model.build_in_name_scope()
for p1, p2 in zip(model.weights, new_model.weights):
self.assertTrue(np.allclose(p1.numpy(), p2.numpy()))
@@ -632,7 +632,7 @@ class TFModelPushToHubTester(unittest.TestCase):
)
model = TFBertModel(config)
# Make sure model is properly initialized
model.build()
model.build_in_name_scope()
logging.set_verbosity_info()
logger = logging.get_logger("transformers.utils.hub")
@@ -701,7 +701,7 @@ class TFModelPushToHubTester(unittest.TestCase):
)
model = TFBertModel(config)
# Make sure model is properly initialized
model.build()
model.build_in_name_scope()
model.push_to_hub("valid_org/test-model-tf-org", token=self._token)