opencv-course
opencv-course copied to clipboard
ValueError: Traceback (most recent call last)
# Create our model (returns a compiled model)
model = canaro.models.createSimpsonsModel(IMG_SIZE=IMG_SIZE, channels=channels, output_dim=len(characters),
loss='binary_crossentropy', decay=1e-7, learning_rate=0.001, momentum=0.9,
nesterov=True)
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.
how to fix this?
# Create our model (returns a compiled model) model = canaro.models.createSimpsonsModel(IMG_SIZE=IMG_SIZE, channels=channels, output_dim=len(characters), loss='binary_crossentropy', decay=1e-7, learning_rate=0.001, momentum=0.9, nesterov=True)
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.
how to fix this?
use this code instead: #this is the import statements you need to add import tensorflow as tf import keras from keras.models import Sequential, Model from keras.layers import Conv2D, Flatten, MaxPooling2D, Dense, Input, Reshape, Concatenate, GlobalAveragePooling2D, BatchNormalization, Dropout, Activation, GlobalMaxPooling2D from keras.utils import Sequence
#this is the functional code used to create the model
def create_ST_layer(input_shape = (64, 128, 3)): input_img = Input(shape=input_shape) model = Conv2D(48, kernel_size=(5, 5), input_shape = input_shape, strides = (1, 1), activation = "relu")(input_img) model = MaxPooling2D(pool_size=(2, 2), strides = (2, 2))(model) model = Conv2D(32, kernel_size=(5, 5), strides = (1, 1), activation = "relu")(model) model = MaxPooling2D(pool_size=(2, 2), strides = (2, 2))(model) model = Dense(50, activation = "relu")(model) model = Dense(6)(model) model = tf.keras.Model(inputs=input_img, outputs= model) return model
#to print the summary
model = create_ST_layer() model.summary()
Hope this helps!!!!
The best solution I found was to modify the simpsons.py file as stated in the answer here: https://stackoverflow.com/a/75951851/17870878.