forked from openai/baselines
-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Added Saving functionality. #3
Merged
Merged
Changes from 3 commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
67df72f
Supports for Madras Env
buridiaditya 2d5593f
Merge branch 'master' of https://github.com/buridiaditya/baselines in…
rudrasohan bba5cfc
added saving function for ddpg
rudrasohan 3e28aee
fixed typos
rudrasohan f66db73
fixed typos 1
rudrasohan 44e1b53
fixed loader
rudrasohan a33f0e1
prevent file overwriting
rudrasohan 0ddec01
removed specific path
rudrasohan File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -42,6 +42,8 @@ def learn(network, env, | |
tau=0.01, | ||
eval_env=None, | ||
param_noise_adaption_interval=50, | ||
load_path = None, | ||
save_path = '<specify/path>' | ||
**network_kwargs): | ||
|
||
set_global_seeds(seed) | ||
|
@@ -58,7 +60,7 @@ def learn(network, env, | |
rank = 0 | ||
|
||
nb_actions = env.action_space.shape[-1] | ||
assert (np.abs(env.action_space.low) == env.action_space.high).all() # we assume symmetric actions. | ||
#assert (np.abs(env.action_space.low) == env.action_space.high).all() # we assume symmetric actions. | ||
|
||
memory = Memory(limit=int(1e6), action_shape=env.action_space.shape, observation_shape=env.observation_space.shape) | ||
critic = Critic(network=network, **network_kwargs) | ||
|
@@ -91,6 +93,9 @@ def learn(network, env, | |
batch_size=batch_size, action_noise=action_noise, param_noise=param_noise, critic_l2_reg=critic_l2_reg, | ||
actor_lr=actor_lr, critic_lr=critic_lr, enable_popart=popart, clip_norm=clip_norm, | ||
reward_scale=reward_scale) | ||
|
||
if load_path is not None: | ||
agent.load(load_path) | ||
logger.info('Using agent with the following configuration:') | ||
logger.info(str(agent.__dict__.items())) | ||
|
||
|
@@ -269,5 +274,10 @@ def as_scalar(x): | |
with open(os.path.join(logdir, 'eval_env_state.pkl'), 'wb') as f: | ||
pickle.dump(eval_env.get_state(), f) | ||
|
||
os.mkdirs(logdir,exist_ok=True) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Error in python mkdirs does not exist |
||
savepath = os.path.join(save_path, str(epoch)) | ||
print('Saving to ',savepath) | ||
agent.save(savepath) | ||
|
||
|
||
return agent |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missed a comma