dog*_*ogs 2 python-3.x keras tensorflow tf.keras tensorflow2.0
In keras using tensorflow 1 I could ModelCheckpoint(filepath) and the saved file was a called filepath and then I could call model = load_model(filepath) to load the saved model.
Now the equivalent in tensorflow 2 the ModelCheckpoint creates a directory called filepath and when I follow the documentation here to load the saved model I have to create an empty model then call model.load_weights(filepath).
Here is my callback and fit:
filepath = "filepath"
checkpoint = tf.keras.callbacks.ModelCheckpoint(filepath=filepath, mode='max', monitor='val_accuracy', verbose=2, save_best_only=True)
callbacks_list = [checkpoint]
model.fit(train_dataset, validation_data=y_test_dataset, validation_steps=BATCH_SIZE, callbacks=callbacks_list, epochs=5000, verbose=2, steps_per_epoch=(X_train_deleted_nans.shape[0]//BATCH_SIZE))
Run Code Online (Sandbox Code Playgroud)
Doing model.load_weights(filepath) in another script I get the following error:
OSError: Unable to open file (unable to open file: name = 'filepath', errno = 13, error message = 'Permission denied', flags = 0, o_flags = 0)
I would like to get some help on why I would be getting a permission denied error for a model that I created.
.hdf5在保存模型权重时尝试检查点,同时包含扩展。
filepath = "filepath/model.hdf5"
checkpoint = tf.keras.callbacks.ModelCheckpoint(filepath=filepath, mode='max', monitor='val_accuracy', verbose=2, save_best_only=True)
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1516 次 |
| 最近记录: |