dashee87 / blogScripts

Repository for code used in my blog posts
MIT License
386 stars 247 forks source link

OSError: Unable to open file (unable to open file: name = 'eth_model_randseed_775.h5', errno = 2, error message = 'No such file or directory', flags = 0, o_flags = 0) #2

Open gopinathankm opened 6 years ago

gopinathankm commented 6 years ago

I tried play with notebook from Github. Why I am getting following error when I run following cell:

`# assuming the previous cell was completed, this cell loads in the different initializations _# and calculates the average mean absolute error (mae) from keras.models import load_model eth_preds = [] bt_preds = [] for rand_seed in range(775,800): temp_model = load_model('eth_modelrandseed%d.h5'%rand_seed) eth_preds.append(np.mean(abs(np.transpose(temp_model.predict(LSTM_test_inputs))- (test_set['eth_Close'].values[window_len:]/test_set['eth_Close'].values[:-window_len]-1)))) temp_model = load_model('bt_modelrandseed%d.h5'%rand_seed) bt_preds.append(np.mean(abs(np.transpose(temp_model.predict(LSTM_test_inputs))- (test_set['bt_Close'].values[window_len:]/test_set['bt_Close'].values[:-windowlen]-1)))) Error

OSError Traceback (most recent call last)

in () 7 bt_preds = [] 8 for rand_seed in range(775,800): ----> 9 temp_model = load_model('eth_model_randseed_%d.h5'%rand_seed) 10 eth_preds.append(np.mean(abs(np.transpose(temp_model.predict(LSTM_test_inputs))- 11 (test_set['eth_Close'].values[window_len:]/test_set['eth_Close'].values[:-window_len]-1)))) ~/anaconda3/lib/python3.6/site-packages/keras/models.py in load_model(filepath, custom_objects, compile) 231 return custom_objects[obj] 232 return obj --> 233 with h5py.File(filepath, mode='r') as f: 234 # instantiate model 235 model_config = f.attrs.get('model_config') ~/anaconda3/lib/python3.6/site-packages/h5py/_hl/files.py in __init__(self, name, mode, driver, libver, userblock_size, swmr, **kwds) 267 with phil: 268 fapl = make_fapl(driver, libver, **kwds) --> 269 fid = make_fid(name, mode, userblock_size, fapl, swmr=swmr) 270 271 if swmr_support: ~/anaconda3/lib/python3.6/site-packages/h5py/_hl/files.py in make_fid(name, mode, userblock_size, fapl, fcpl, swmr) 97 if swmr and swmr_support: 98 flags |= h5f.ACC_SWMR_READ ---> 99 fid = h5f.open(name, flags, fapl=fapl) 100 elif mode == 'r+': 101 fid = h5f.open(name, h5f.ACC_RDWR, fapl=fapl) h5py/_objects.pyx in h5py._objects.with_phil.wrapper() h5py/_objects.pyx in h5py._objects.with_phil.wrapper() h5py/h5f.pyx in h5py.h5f.open() **OSError: Unable to open file (unable to open file: name = 'eth_model_randseed_775.h5', errno = 2, error message = 'No such file or directory', flags = 0, o_flags = 0)**
dashee87 commented 6 years ago

Hey,

The clue is in the comment at the start of the code, this cell will return errors if the previous cell (no. 35) is not run first. It takes some time to run, so that's why I commented it out. You'll need to uncomment it and write those files to your local directory. Then you should be able to open the files.

gopinathankm commented 6 years ago

Hi David Sheehan Many many thank for your assistance, you can close this issue.

With regards Gopinathan K.M