前提・実現したいこと
Python3.6.7でKerasを用いて機械学習を行っています
画像を学習させて判定させるシステムです
発生している問題・エラーメッセージ
実行すると以下のようなエラーが発生します
Using TensorFlow backend.
Traceback (most recent call last):
File "learn.py", line 12, in <module>
model.load_weights('weight.h5')
File "/usr/local/lib64/python3.6/site-packages/keras/engine/network.py", line 1157, in load_weights
with h5py.File(filepath, mode='r') as f:
File "/usr/local/lib64/python3.6/site-packages/h5py/_hl/files.py", line 312, in init
fid = make_fid(name, mode, userblock_size, fapl, swmr=swmr)
File "/usr/local/lib64/python3.6/site-packages/h5py/_hl/files.py", line 142, 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 = 'weight.h5', errno = 2, error message = 'No such file or directory', flags = 0, o_flags = 0)
該当のソースコード
Python
1#coding: utf-8 2 3import numpy as np 4import h5py 5from keras.models import Sequential, model_from_json 6from keras.layers.core import Dense 7from keras.optimizers import RMSprop 8from keras.preprocessing import image 9 10model = model_from_json(open('model.json').read()) 11 12model.load_weights('weight.h5') 13 14img_path='unExample/a6.jpg' 15img = image.load_img(img_path, target_size=(32,32)) 16x = image.img_to_array(img) 17x = np.expand_dims(x, axis=0) 18x = preprocess_input(x) 19 20features = model.predict(x) 21 22print(features) 23
試したこと
学習のやり直し
h5pyのアップデート
補足情報(FW/ツールのバージョンなど)
OS: ubuntu14.04.5LTS
コンソール上での実行
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2018/12/20 04:43
2018/12/20 04:47 編集
2018/12/20 04:48
2018/12/20 04:50
2018/12/20 04:53
2018/12/20 04:59
2018/12/20 05:02