AppliedDataSciencePartners / DeepReinforcementLearning

A replica of the AlphaZero methodology for deep reinforcement learning in Python
GNU General Public License v3.0
2.02k stars 759 forks source link

OSError: Unable to open file (unable to open file: name = './run_archive/connect4/run0001/models/version0001.h5', errno = 2, error message = 'No such file or directory', flags = 0, o_flags = 0) #11

Closed SCoulY closed 6 years ago

SCoulY commented 6 years ago

I can not play matches between versions:


OSError Traceback (most recent call last)

in () 4 5 env = Game() ----> 6 playMatchesBetweenVersions(env, 1, 1, 1, 10, lg.logger_tourney, 0) ~/DeepReinForcementLearning/DeepReinforcementLearning/funcs.py in playMatchesBetweenVersions(env, run_version, player1version, player2version, EPISODES, logger, turns_until_tau0, goes_first) 19 20 if player1version > 0: ---> 21 player1_network = player1_NN.read(env.name, run_version, player1version) 22 player1_NN.model.set_weights(player1_network.get_weights()) 23 player1 = Agent('player1', env.state_size, env.action_size, config.MCTS_SIMS, config.CPUCT, player1_NN) ~/DeepReinForcementLearning/DeepReinforcementLearning/model.py in read(self, game, run_number, version) 37 38 def read(self, game, run_number, version): ---> 39 return load_model( run_archive_folder + game + '/run' + str(run_number).zfill(4) + "/models/version" + "{0:0>4}".format(version) + '.h5', custom_objects={'softmax_cross_entropy_with_logits': softmax_cross_entropy_with_logits}) 40 41 def printWeightAverages(self): /Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/keras/models.py in load_model(filepath, custom_objects, compile) 235 return custom_objects[obj] 236 return obj --> 237 with h5py.File(filepath, mode='r') as f: 238 # instantiate model 239 model_config = f.attrs.get('model_config') /Library/Frameworks/Python.framework/Versions/3.6/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: /Library/Frameworks/Python.framework/Versions/3.6/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 = './run_archive/connect4/run0001/models/version0001.h5', errno = 2, error message = 'No such file or directory', flags = 0, o_flags = 0)
ezrahn commented 6 years ago

Once you have a set of training models, copy directories under ~run/ to ~run_archive/connect4/run001/, then you should be able to play.

I added a little script in my fork (play_game.py) for a better interface of human playing against AI. See: https://github.com/ezrahn/DeepReinforcementLearning

There are bugs in the initial game model, including

Will try to fix these and contribute back.

ezrahn commented 6 years ago

I just added the validation for human player moves, and a better interface for human to interact with the game. Once the model is trained, copy directories under ~run/ to ~run_archive/connect4/run001/.

To play the game, run: python play_game.py See: https://github.com/ezrahn/DeepReinforcementLearning

SCoulY commented 6 years ago

Sorry for the late reply. I do fix the bug through your instruction, but i found my MacBook Pro can not afford this GPU-hungry program. Thanks anyway.

FireFoxtrott commented 6 years ago

Hello, i have the same problem as SCoulY with

OSError: Unable to open file (unable to open file: name = './run_archive/connect4/run0001/models/version0001.h5', errno = 2, error message = 'No such file or directory', flags = 0, o_flags = 0)

What exactly is the version0001.h5 file?

Thanks for help

zhifengmuyu commented 6 years ago

Hey, ezrahn I met exact the same problem

OSError: Unable to open file (unable to open file: name = './run_archive/connect4/run0001/models/version0001.h5', errno = 2, error message = 'No such file or directory', flags = 0, o_flags = 0)

I've first run the training, but terminate the run before any model file created, now I'd like to restart training again, then above fail popup, any way to solve this?

thanks

DiyuanLu commented 5 years ago

My problem is I model.save_model("model"). It kind shows it's in .h5 format with actually without the extension. When I just write loaded_model = load_model('model'), everything works.