keras/tensorflow 没有找到权重文件 imagenet
keras/tensorflow does not find weights file imagenet
以下最小示例代码
#!/usr/bin/env python3
from tensorflow.contrib.keras.api import keras
model = keras.applications.xception.Xception(input_shape=(299, 299, 3))
失败
File "/usr/local/lib/python3.5/dist-packages/tensorflow/python/keras/_impl/keras/applications/xception.py", line 307, in Xception
model.load_weights(weights)
File "/usr/local/lib/python3.5/dist-packages/tensorflow/python/keras/_impl/keras/engine/topology.py", line 1101, in load_weights
f = h5py.File(filepath, mode='r')
File "/usr/local/lib/python3.5/dist-packages/h5py/_hl/files.py", line 269, in __init__
fid = make_fid(name, mode, userblock_size, fapl, swmr=swmr)
File "/usr/local/lib/python3.5/dist-packages/h5py/_hl/files.py", line 99, in make_fid
fid = h5f.open(name, flags, fapl=fapl)
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 78, in h5py.h5f.open
OSError: Unable to open file (unable to open file: name = 'imagenet', errno = 2, error message = 'No such file or directory', flags = 0, o_flags = 0)
即使在 运行 之前这样做:
rm -r ~/.keras/models/
然后它再次成功下载 https://github.com/fchollet/deep-learning-models/releases/download/v0.4/xception_weights_tf_dim_ordering_tf_kernels.h5
,但随后出现相同的错误。我错过了什么?
我在 Ubuntu 16.04.
上使用 TensorFlow 版本 1.5.0(来自 pip3
的 tensorflow-gpu)
这是 TF-Keras 特有的问题。 GitHub issue 中对此进行了讨论并已修复。据作者介绍,
It was introduced in PR #15146 and it applies to both Xception and
MobileNet.
However, it has been fixed since. If you upgrade to TF 1.6, you will
no longer see this issue. For instance, you can pip install
the TF 1.6
release candidate 1.6.0rc0
as of now.
以下最小示例代码
#!/usr/bin/env python3
from tensorflow.contrib.keras.api import keras
model = keras.applications.xception.Xception(input_shape=(299, 299, 3))
失败
File "/usr/local/lib/python3.5/dist-packages/tensorflow/python/keras/_impl/keras/applications/xception.py", line 307, in Xception
model.load_weights(weights)
File "/usr/local/lib/python3.5/dist-packages/tensorflow/python/keras/_impl/keras/engine/topology.py", line 1101, in load_weights
f = h5py.File(filepath, mode='r')
File "/usr/local/lib/python3.5/dist-packages/h5py/_hl/files.py", line 269, in __init__
fid = make_fid(name, mode, userblock_size, fapl, swmr=swmr)
File "/usr/local/lib/python3.5/dist-packages/h5py/_hl/files.py", line 99, in make_fid
fid = h5f.open(name, flags, fapl=fapl)
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 78, in h5py.h5f.open
OSError: Unable to open file (unable to open file: name = 'imagenet', errno = 2, error message = 'No such file or directory', flags = 0, o_flags = 0)
即使在 运行 之前这样做:
rm -r ~/.keras/models/
然后它再次成功下载 https://github.com/fchollet/deep-learning-models/releases/download/v0.4/xception_weights_tf_dim_ordering_tf_kernels.h5
,但随后出现相同的错误。我错过了什么?
我在 Ubuntu 16.04.
上使用 TensorFlow 版本 1.5.0(来自pip3
的 tensorflow-gpu)
这是 TF-Keras 特有的问题。 GitHub issue 中对此进行了讨论并已修复。据作者介绍,
It was introduced in PR #15146 and it applies to both Xception and MobileNet.
However, it has been fixed since. If you upgrade to TF 1.6, you will no longer see this issue. For instance, you can
pip install
the TF 1.6 release candidate1.6.0rc0
as of now.