baselines icon indicating copy to clipboard operation
baselines copied to clipboard

How does the save/restore model work?

Open harrywang-1523 opened this issue 8 years ago • 4 comments

In the baselines/deepq/experiments/train_pong or train_cartpole, the model is saved as a .pkl file. This method works fine. However, if we run directly from the command line, we get a folder that contains .data .meta .index files. I tried to run the following command, but only getting the following warnings: python3 -m baselines.run --alg=deepq --env=PongNoFrameskip-v4 --num_timesteps=1e6 --save_path=./saved_models/pong-1e4_deepq python3 -m baselines.run --alg=deepq --env=PongNoFrameskip-v4 --num_timesteps=1e5 --load_path=./saved_models/pong-1e4_deepq --play

FileNotFoundError: [Errno 2] No such file or directory: '/users/harry/saved_models/pong-1e4_deepq'

Can anyone help me with this problem? Thanks!

harrywang-1523 avatar Nov 02 '18 13:11 harrywang-1523

I figure out that the problem is probably due to the change from save_state/load_state to save_variables/load_variables. I replaced the save_state/load_state with save_variables/load_variables and then things work fine.

harrywang-1523 avatar Nov 03 '18 09:11 harrywang-1523

what is this save_variables and how is it different from save_path ?

I ran this ==>python -m baselines.run --alg=ppo2 --network=lstm --num_timesteps=1e6 --env=Reacher-v2 --num_env=4 --nminibatches=2 --value_network=shared --save_path=/mnt/data/mamini/models/reacher_1e6_ppo2/

and got the same error

amini2nt avatar Nov 06 '18 07:11 amini2nt

@amini2nt in your case I think the problem is trailing slash (saved models are files, not folders). Also make sure the process has rights to create directories and write in that location (/mnt/data/mamini/models/). @harrywang-1523 Current version of baselines.deepq uses save_variables / load_variables... Did you mean you replaced save_variables / load_variables with save_state / load_state? Also, I am having hard time reproducing the issue (the file ./saved_models/pong-1e4_deepq is created, new network is loaded etc). Could you please pull latest master version, try again and report here if the error persists?

pzhokhov avatar Nov 09 '18 23:11 pzhokhov

Fixed it by adding a line in run.py file. In train method, after alg_kwargs.update(extra_args), before env = build_env(args) add this : alg_kwargs['checkpoint_path'] = args.save_path

MengqiYe avatar Feb 01 '19 05:02 MengqiYe