Skip to content

ValueError: decay is deprecated in the new Keras optimizer, pleasecheck the docstring for valid arguments, or use the legacy optimizer, e.g., tf.keras.optimizers.legacy.SGD. #38

@MrIzzat

Description

@MrIzzat

The model creation part of the course at 3:31:00 raises some errors due to the new versions of TensorFlow changing some things around with how optimizers work. I recommend modifying the simpsons.py file as specified by this answer here.

The issue is specifically with this code in the tutorial:

model = canaro.models.createSimpsonsModel(IMG_SIZE=imageSize, channels=channels, output_dim=len(characters),
                                         loss='binary_crossentropy', decay=1e-7, learning_rate=0.001, momentum=0.9,
                                         nesterov=True)

Which can be fixed by adding this line in the simpsons.py file right before the return line:

import tensorflow as tf
lr_schedule = tf.keras.optimizers.schedules.ExponentialDecay(
    initial_learning_rate=0.01,
    decay_steps=10000,
    decay_rate=0.9)
optimizer = tf.keras.optimizers.Adam(learning_rate=lr_schedule)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions