clothing-segmentation icon indicating copy to clipboard operation
clothing-segmentation copied to clipboard

NameError: name 'callbacks' is not defined

Open Jonovono opened this issue 1 year ago • 4 comments

Pretty noob to ML, trying to get this project to run and getting this error. Can you help me out?


NameError Traceback (most recent call last) in <cell line: 1>() 4 validation_steps=len(val_gen), 5 epochs=num_epoch, ----> 6 callbacks=callbacks, 7 verbose = 1)

NameError: name 'callbacks' is not defined

Jonovono avatar Jun 17 '23 20:06 Jonovono

Greetings @Jonovono, You could define callbacks before starting the model training. Below, I provide an example of a callback. Please set it before training the model.

for more information: callbacks


import tensorflow as tf
from keras.callbacks import ModelCheckpoint

callback_checkpoint = ModelCheckpoint(
    model_filename, 
    verbose=1, 
    monitor='loss', 
    save_weights_only=True,
    save_best_only=True,
    mode='min'
)

callbacks = [
    callback_checkpoint,
    tf.keras.callbacks.ReduceLROnPlateau(),
]

mberkay0 avatar Jun 24 '23 12:06 mberkay0

Thanks @mberkay0 , I think that helped but then get onto this error:

RuntimeError: You must compile your model before training/testing. Use model.compile(optimizer, loss).

I'm willing to pay you for an hour of your time or so to walk me through this if you are up for it?

Jonovono avatar Jun 24 '23 17:06 Jonovono

I added this:

model.compile(optimizer='adam',
              loss='sparse_categorical_crossentropy',
              metrics=['accuracy'])

Seems to have gotten past that error, but now get this:

Node: 'deeplabv3plus/tf.compat.v1.nn.depthwise_conv2d_80/depthwise/SpaceToBatchND'
padded_shape[0]=32 is not divisible by block_shape[0]=6
	 [[{{node deeplabv3plus/tf.compat.v1.nn.depthwise_conv2d_80/depthwise/SpaceToBatchND}}]] [Op:__inference_train_function_37058]

Jonovono avatar Jun 24 '23 17:06 Jonovono

@mberkay0 Can I contact you privately?

RichardLindhout avatar Nov 23 '23 12:11 RichardLindhout