我在 Tensorflow 之上使用 Python 和 Keras 来训练我的神经网络。
当我从 Ubuntu 16.04 切换到 Windows 10 时,当我运行以下命令时,我的模型无法再保存:

filepath = "checkpoint-"+str(f)+model_type+"-"+optimizer_name+"-{epoch:02d}-{loss:.3f}.hdf5"
checkpoint = ModelCheckpoint(filepath, monitor='loss', verbose=1, save_best_only=True, mode='min')
callbacks_list = [checkpoint]

后来:
model.fit(X, y,
      batch_size=128,
      epochs=1,
      shuffle=False,
      callbacks=callbacks_list)

我收到此错误:



我通过 conda 安装了 Keras 2.0.8 和 h5py 2.7.0。

我试过了
filepath = "checkpoint-"+str(f)+model_type+"-"+optimizer_name+"-{epoch:02d}-{loss:.3f}.hdf5"

with open(filepath, "w") as f:
  f.write("Test.")

并得到了类似的错误:

最佳答案

当我从文件路径中删除 str(f) 时,它​​起作用了。f 是一个整数,我不知道它为什么会导致错误,但是从字符串中删除它解决了我的问题。

如果您确切知道原因,请告诉我。

关于python - OSError 无法创建文件 - 无效参数,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/46141223/

10-12 21:09