打印保存的纪元号

问题描述 投票:0回答:1

我将模型的权重保存在文件路径中,现在当我加载权重时,我会看到以下内容:

<tensorflow.python.checkpoint.checkpoint.CheckpointLoadStatus object at 0x7b3e7e6e5000>

而且我不知道模型保存在哪个纪元,因为我想继续训练那个纪元的模型,我不知道它是什么纪元。有人可以帮助我了解模型保存的纪元吗?

#save the weights
checkpoint_filepath = '/content/pamap2-fedavg-128'
checkpoint_callback = tf.keras.callbacks.ModelCheckpoint(
filepath=checkpoint_filepath,
save_weights_only=True,
monitor='acc',  
mode='auto',
save_best_only=False,
verbose=1,
)
#load the weights
checkpoint_filepath = '/content/pamap2-fedavg-128'
print (global_model.load_weights(checkpoint_filepath)
tensorflow machine-learning keras deep-learning checkpoint
1个回答
0
投票

因此根据ModelCheckPoint的文档,您可以通过'{epoch:02}'传递纪元数字格式。例如:

checkpoint_callback = tf.keras.callbacks.ModelCheckpoint(
filepath='/content/pamap2-fedavg-128_{epoch_02d}.h5',
save_weights_only=True,
monitor='acc',  
mode='auto',
save_best_only=False,
verbose=1,
)
© www.soinside.com 2019 - 2024. All rights reserved.