eng
eng

Reputation: 3

model checkpoint - none values not supported

I am new to the use of model checkpoints. I am on Keras 3.4.1. I am having some difficulty with loading and using saved models. It produces the error 'None values not supported'. I trained a model as follows. When I reloaded the best model and tried to use it to make a prediction, it gave the following error. I wonder if anyone knows why? Many thanks in advance.

model = keras.Sequential(
    [
        layers.Input(shape=(x_train.shape[1], x_train.shape[2])),
        layers.Conv1D(
            filters=32,
            kernel_size=7,
            padding="same",
            strides=2,
            activation="relu",
        ),
        layers.Dropout(rate=0.2),
        layers.Conv1D(
            filters=16,
            kernel_size=7,
            padding="same",
            strides=2,
            activation="relu",
        ),
        layers.Conv1DTranspose(
            filters=16,
            kernel_size=7,
            padding="same",
            strides=2,
            activation="relu",
        ),
        layers.Dropout(rate=0.2),
        layers.Conv1DTranspose(
            filters=32,
            kernel_size=7,
            padding="same",
            strides=2,
            activation="relu",
        ),
        layers.Conv1DTranspose(filters=x_train.shape[2], kernel_size=7, padding="same"),
    ]
)

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

checkpoint_filepath = 'test.keras'
model_checkpoint_callback = keras.callbacks.ModelCheckpoint(
    filepath=checkpoint_filepath,
    monitor='val_accuracy',
    mode='max',
    save_best_only=True,options=None)
NUM_EPOCHS=20
BATCH_SIZE=100
history=model.fit(x_train,x_train, 
                  batch_size=BATCH_SIZE, 
                  epochs=NUM_EPOCHS,
                  validation_split=0.2,
                  shuffle=True,callbacks=[model_checkpoint_callback])
saved=keras.models.load_model(checkpoint_filepath)
x_train_pred = saved.fit(x_train)

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/gpfs3/well/combat/users/nif917/python/keras/lib/python3.10/site-packages/keras/src/utils/traceback_utils.py", line 122, in error_handler
    raise e.with_traceback(filtered_tb) from None
  File "/gpfs3/well/combat/users/nif917/python/keras/lib/python3.10/site-packages/optree/ops.py", line 747, in tree_map
    return treespec.unflatten(map(func, *flat_args))
ValueError: None values not supported.

Upvotes: 0

Views: 73

Answers (0)

Related Questions