code:
model = create_model()
model.compile(optimize=tf.keras.optimizers.Adam(learning_rate=2e-5),
loss=tf.keras.losses.BinaryCrossentropy(),
metrics=[tf.keras.metrics.BinaryAccuracy()])
model.summary()
error:
TypeError Traceback (most recent call last)
<ipython-input-58-cdba04f466b1> in <module>()
2 model.compile(optimize=tf.keras.optimizers.Adam(learning_rate=2e-5),
3 loss=tf.keras.losses.BinaryCrossentropy(),
----> 4 metrics=[tf.keras.metrics.BinaryAccuracy()])
5 model.summary()
1 frames
/usr/local/lib/python3.7/dist-packages/keras/engine/training.py in _validate_compile(self, optimizer, metrics, **kwargs)
2981 invalid_kwargs = set(kwargs) - {'sample_weight_mode'}
2982 if invalid_kwargs:
-> 2983 raise TypeError('Invalid keyword argument(s) in `compile()`: '
2984 f'{(invalid_kwargs,)}. Valid keyword arguments include '
2985 '"cloning", "experimental_run_tf_function", "distribute",'
TypeError: Invalid keyword argument(s) in `compile()`: ({'optimize'},). Valid keyword arguments include "cloning", "experimental_run_tf_function", "distribute", "target_tensors", or "sample_weight_mode".
can someone have a look into this? here building a model for fine-tuning BERT for text classification
I was able to replicate above issue using sample code as shown below
Output:
Fixed code:
Above TypeError clearly guide and it is due to typo, please can you change
optimize
tooptimizer
as shown belowFor more details please find the gist for reference.