Closed Humbulani1234 closed 8 months ago
cc @Rocketknight1
Hi @Humbulani1234, there are two issues here. The first is that TF is indeed throwing errors when optimizer=None
, which used to work. I opened a PR to fix it at #29597.
You may also wish to add the arguments --do_train
and --do_eval
to your invocation of the example. I've updated the README to include them!
System Info
Who can help?
No Response
Information
Tasks
examples
folder (such as GLUE/SQuAD, ...)Reproduction
While I was trying out the examples in the
transformers
source code, theexamples
directory, I experienced an issue while I was trying to run the exampletensorflow.textclassification.run_text_classification
- the bash command line as:python run_text_classification.py --model_name_or_path distilbert-base-cased --train_file training_data.json --validation_file validation_data.json --output_dir output
, accordingly as per thetestclassifiication.README.md
instructions.Here is the error:
I then decided to read through the source code starting from the
run_text_classification.main
. This function callscompile.model
which has a signature:model.compile(optimizer=optimizer, metrics=metrics)
, and function acceptsoptimizer
as one of the keyword arguments, and depending on the below cross section block of code from themain
functionoptimizer
may take the valueNone
:if the
else
block of code is executed andoptimizer
is indeed set toNone
, it then overrides the assignment of theoptimizer
, which is equal to"rmsprop"' by default, argument in the function:
keras.src.engine.training.compile` where its signature is given by:This then leads to all sorts of issues. I then decided to assign
optimizer
in theelse
block of code to:optimizer = None or "rmsprop"
and the code worked perfectly. I'm sure there could be better fix than thishack
, which maybe submitted with a PR should this prove to be a genuine bug.The Stacktrace for function calls:
Environment
Expected behavior
The module
run_text_classification
was expected to execute normally and construct the model in theoutput
directory as per theREADME.md
instructions.