I am using keras-tuner in order to obtain the best set of hyperparameters for my model. Here is the training script:
tuner = kt.Hyperband(
hypermodel=build_model,
objective="val_accuracy",
max_epochs=1000,
factor=3,
hyperband_iterations=1,
directory=TrainingSpecific.SAVE_DIR,
project_name="cnn_tunning"
)
early_stop_callback = tf.keras.callbacks.EarlyStopping(monitor='val_loss',
mode='min',
patience=10,
min_delta=0.0002)
train_filenames = get_filenames(f'/*train_fold.csv')
val_filenames = get_filenames(f'/*val_fold.csv')
x_train_list, y_train_list = data_reader(train_filenames)
training_generator = custom_generator(x_train_list, y_train_list)
x_val_list, y_val_list = data_reader(val_filenames)
validation_generator = custom_generator(x_val_list, y_val_list)
print("********** Begin search **********")
tuner.search(
training_generator,
steps_per_epoch=len(train_filenames),
validation_data=validation_generator,
validation_steps=len(val_filenames),
callbacks=[early_stop_callback],
workers=1
)
# grab the best hyperparameters
print("********** End of search **********")
bestHP = tuner.get_best_hyperparameters(num_trials=1)[0]
Now what I have found is that after the hyperband starts using a decent number of iterations and the callback I set up should come into play I get this error: W tensorflow/core/framework/op_kernel.cc:1733] INVALID_ARGUMENT: ValueError: Could not find callback with key=pyfunc_11900 in the registry.
However it just proceeds to the next trial so I'm not sure what is going on, can someone explain why it can't find the callback?
I'm using tensorflow 2.8 and keras-tuner 1.1.2
from Keras-tuning can't find callback
No comments:
Post a Comment