小言_互联网的博客

tf.keras: Unable to create group (name already exists)

2267人阅读  评论(0)

环境: tensorflow2.0.0

在使用tf.kerasModelCheckpoint

keras.callbacks.ModelCheckpoint(
        filepath='mymodel_{epoch}.h5', save_weights_only=True, save_freq=5)

出现错误

in save_weights
    saving.save_weights_to_hdf5_group(f, self.layers)
  File "D:\Anaconda3\envs\py37\lib\site-packages\tensorflow_core\python\keras\saving\hdf5_format.py", line 625, in save_weights_to_hdf5_group
    g = f.create_group(layer.name)
  File "D:\Anaconda3\envs\py37\lib\site-packages\h5py\_hl\group.py", line 68, in create_group
    gid = h5g.create(self.id, name, lcpl=lcpl, gcpl=gcpl)
  File "h5py\_objects.pyx", line 54, in h5py._objects.with_phil.wrapper
  File "h5py\_objects.pyx", line 55, in h5py._objects.with_phil.wrapper
  File "h5py\h5g.pyx", line 161, in h5py.h5g.create
ValueError: Unable to create group (name already exists)

解决方法:

link Seems to be due to layer naming convention in Keras. Check out this issue: github.com/keras-team/keras/issues/12195

link I met the same error, I solved it by saving the model with .tf instead of .h5
Plus, I am using TensorFlow 2.0, the default saving format is .tf


转载:https://blog.csdn.net/grllery/article/details/102489846
查看评论
* 以上用户言论只代表其个人观点,不代表本网站的观点或立场