无法保存模型权重

时间:2018-09-20 20:49:22

标签: keras deep-learning

有没有人看到此错误消息:

OSError: Unable to create file (unable to open file: name = './snapshots/resnet50_csv_01.h5', errno = 2, error message = 'No such file or directory', flags = 13, o_flags = 242)

我不确定我在做什么错。

完整:

  Epoch 00001: saving model to ./snapshots/resnet50_csv_01.h5
Traceback (most recent call last):
  File "../keras-retinanet-0.1/keras_retinanet/bin/train.py", line 264, in <module>
    main()
  File "../keras-retinanet-0.1/keras_retinanet/bin/train.py", line 260, in main
    callbacks=callbacks,
  File "/gpfs0/users/lindgren/pstrain/virtual_enviroments/final_placenta_virtual_enviroment/lib/python3.6/site-packages/keras/legacy/interfaces.py", line 91, in wrapper
    return func(*args, **kwargs)
  File "/gpfs0/users/lindgren/pstrain/virtual_enviroments/final_placenta_virtual_enviroment/lib/python3.6/site-packages/keras/engine/training.py", line 1415, in fit_generator
    initial_epoch=initial_epoch)
  File "/gpfs0/users/lindgren/pstrain/virtual_enviroments/final_placenta_virtual_enviroment/lib/python3.6/site-packages/keras/engine/training_generator.py", line 247, in fit_generator
    callbacks.on_epoch_end(epoch, epoch_logs)
  File "/gpfs0/users/lindgren/pstrain/virtual_enviroments/final_placenta_virtual_enviroment/lib/python3.6/site-packages/keras/callbacks.py", line 77, in on_epoch_end
    callback.on_epoch_end(epoch, logs)
  File "../keras-retinanet-0.1/keras_retinanet/bin/../../keras_retinanet/callbacks/common.py", line 30, in on_epoch_end
    self.callback.on_epoch_end(epoch, logs=logs)
  File "/gpfs0/users/lindgren/pstrain/virtual_enviroments/final_placenta_virtual_enviroment/lib/python3.6/site-packages/keras/callbacks.py", line 455, in on_epoch_end
    self.model.save(filepath, overwrite=True)
  File "/gpfs0/users/lindgren/pstrain/virtual_enviroments/final_placenta_virtual_enviroment/lib/python3.6/site-packages/keras/engine/network.py", line 1085, in save
    save_model(self, filepath, overwrite, include_optimizer)
  File "/gpfs0/users/lindgren/pstrain/virtual_enviroments/final_placenta_virtual_enviroment/lib/python3.6/site-packages/keras/engine/saving.py", line 105, in save_model
    f = h5py.File(filepath, mode='w')
  File "/gpfs0/users/lindgren/pstrain/virtual_enviroments/final_placenta_virtual_enviroment/lib/python3.6/site-packages/h5py/_hl/files.py", line 312, in __init__
    fid = make_fid(name, mode, userblock_size, fapl, swmr=swmr)
  File "/gpfs0/users/lindgren/pstrain/virtual_enviroments/final_placenta_virtual_enviroment/lib/python3.6/site-packages/h5py/_hl/files.py", line 148, in make_fid
    fid = h5f.create(name, h5f.ACC_TRUNC, fapl=fapl, fcpl=fcpl)
  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/h5f.pyx", line 98, in h5py.h5f.create
OSError: Unable to create file (unable to open file: name = './snapshots/resnet50_csv_01.h5', errno = 2, error message = 'No such file or directory', flags = 13, o_flags = 242)

1 个答案:

答案 0 :(得分:1)

我认为这很简单,因为您要保存到的目录不存在。您需要先创建目录。