huggingface / notebooks

Notebooks using the Hugging Face libraries 🤗
Apache License 2.0
3.44k stars 1.46k forks source link

Resolve Libraries Conflict in chapter3/section3_tf.ipynb #495

Open heispv opened 1 month ago

heispv commented 1 month ago

As documented in Issue #19262 on the Keras GitHub repository, there was a conflict between the Transformers and Keras libraries. Specifically, executing the following code resulted in an error associated with the Adam optimizer:

import tensorflow as tf

model = TFAutoModelForSequenceClassification.from_pretrained('checkpoint', num_labels=2)
loss = tf.keras.losses.SparseCategoricalCrossentropy(from_logits=True)
model.compile(optimizer='opt', loss=loss, metrics=["accuracy"])

I have updated the notebook to resolve this issue. With the modifications applied, the error no longer occurs, ensuring compatibility between the two libraries.

review-notebook-app[bot] commented 1 month ago

Check out this pull request on  ReviewNB

See visual diffs & provide feedback on Jupyter Notebooks.


Powered by ReviewNB