tf_keras==2.20.1
self._model = TFDistilBertForTokenClassification.from_pretrained('models/NameEntityRecognition', num_labels=len(self._unique_tags))
self._model.compile(optimizer=Adam(learning_rate=self._learning_rate), loss=self._model.hf_compute_loss, metrics=['accuracy'])
I have tried os.environ['TF_USE_LEGACY_KERAS'] = '1'
but to no avail.
File "/usr/src/Python/pAIthon/NameEntityRecognition.py", line 52, in BuildTrainModel
self._model.compile(optimizer=Adam(learning_rate=self._learning_rate), loss=self._model.hf_compute_loss, metrics=['accuracy']) # can also use any keras loss fn
~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/khteh/.local/share/virtualenvs/pAIthon-GaqEDHQT/lib/python3.13/site-packages/transformers/modeling_tf_utils.py", line 1547, in compile
super().compile(
~~~~~~~~~~~~~~~^
optimizer=optimizer,
^^^^^^^^^^^^^^^^^^^^
...<6 lines>...
**kwargs,
^^^^^^^^^
)
^
File "/home/khteh/.local/share/virtualenvs/pAIthon-GaqEDHQT/lib/python3.13/site-packages/tf_keras/src/utils/traceback_utils.py", line 70, in error_handler
raise e.with_traceback(filtered_tb) from None
File "/home/khteh/.local/share/virtualenvs/pAIthon-GaqEDHQT/lib/python3.13/site-packages/tf_keras/src/optimizers/__init__.py", line 335, in get
raise ValueError(
f"Could not interpret optimizer identifier: {identifier}"
)
ValueError: Could not interpret optimizer identifier: <keras.src.optimizers.adam.Adam object at 0x7e2fc0491010>
Comment From: dhantule
Hi @khteh, please provide some reproducible code to reproduce this issue
Comment From: khteh
https://github.com/khteh/pAIthon/blob/master/NameEntityRecognition.py
Comment From: monicadsong
Hi @khteh --
The Keras team would like to learn more about your Keras usage. Please thumbs up this comment if you are open to speaking with us and we'll reach out to you over email.
Thank you so much! Monica, Keras Product Manager