Skip to content
Advertisement

TypeError: multiple values for argument ‘weight_decay’

I am using an AdamW optimizer that uses cosine decay with a warmup learning scheduler. I have written the custom scheduler from scratch and using the AdamW optimizer provided by the TensorFlow addons library.

JavaScript
JavaScript

I get the following error prompt where it says that weight_decay has multiple arguments

JavaScript

What is causing problem and how do I resolve this?

Advertisement

Answer

The problem is that weight_decay is the first positional argument of tfa.optimizers.AdamW. In

JavaScript

you hand over a positional argument and a kw argument weight_decay. This causes the error. According to the documentation, learning rate is the second positional parameter (even though optional), not the first.

Just write

JavaScript

or

JavaScript

or

JavaScript
User contributions licensed under: CC BY-SA
7 People found this is helpful
Advertisement