Add tf_keras imports to prepare for Keras 3 (#28588)
* Port core files + ESM (because ESM code is odd) * Search-replace in modelling code * Fix up transfo_xl as well * Fix other core files + tests (still need to add correct import to tests) * Fix cookiecutter * make fixup, fix imports in some more core files * Auto-add imports to tests * Cleanup, add imports to sagemaker tests * Use correct exception for importing tf_keras * Fixes in modeling_tf_utils * make fixup * Correct version parsing code * Ensure the pipeline tests correctly revert to float32 after each test * Ensure the pipeline tests correctly revert to float32 after each test * More tf.keras -> keras * Add dtype cast * Better imports of tf_keras * Add a cast for tf.assign, just in case * Fix callback imports
This commit is contained in:
@@ -22,6 +22,7 @@ if is_tf_available():
|
||||
import tensorflow as tf
|
||||
|
||||
from transformers import TFCvtForImageClassification, TFCvtModel
|
||||
from transformers.modeling_tf_utils import keras
|
||||
from transformers.models.cvt.modeling_tf_cvt import TF_CVT_PRETRAINED_MODEL_ARCHIVE_LIST
|
||||
|
||||
|
||||
@@ -191,10 +192,10 @@ class TFCvtModelTest(TFModelTesterMixin, PipelineTesterMixin, unittest.TestCase)
|
||||
|
||||
@unittest.skip(reason="Get `Failed to determine best cudnn convolution algo.` error after using TF 2.12+cuda 11.8")
|
||||
def test_keras_fit_mixed_precision(self):
|
||||
policy = tf.keras.mixed_precision.Policy("mixed_float16")
|
||||
tf.keras.mixed_precision.set_global_policy(policy)
|
||||
policy = keras.mixed_precision.Policy("mixed_float16")
|
||||
keras.mixed_precision.set_global_policy(policy)
|
||||
super().test_keras_fit()
|
||||
tf.keras.mixed_precision.set_global_policy("float32")
|
||||
keras.mixed_precision.set_global_policy("float32")
|
||||
|
||||
def test_forward_signature(self):
|
||||
config, _ = self.model_tester.prepare_config_and_inputs_for_common()
|
||||
|
||||
Reference in New Issue
Block a user