Skip to content
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

Rename self.evaluate for off-policy algos #1139

Merged
merged 1 commit into from
Mar 6, 2020
Merged

Conversation

zequnyu
Copy link
Member

@zequnyu zequnyu commented Jan 19, 2020

  • also removes duplicate performance recording after evaluate_performance() being introduced.

@zequnyu zequnyu requested a review from a team as a code owner January 19, 2020 20:00
Copy link
Member

@ryanjulian ryanjulian left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See my comment about deleting this bool altogether. It would make these classes less likely to suffer a logic error in the future, because storing conditionals is dangerous (it makes your class a state machine).

Can you make the members in these classes _private while you're here?

@@ -65,7 +65,7 @@ def __init__(self,
self.min_buffer_size = min_buffer_size
self.rollout_batch_size = rollout_batch_size
self.reward_scale = reward_scale
self.evaluate = False
self._first_buffer_size_steps_done = False
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This tracks whether the replay buffer is at least min_buffer_size right? So why not just test that directly?

self.replay_buffer.n_transitions_stored >= self.min_buffer_size

Perhaps the original author was concerned about having such a long conditional everywhere? If so, you can add a helper property:

@property
def _buffer_prefilled(self):
    return self.replay_buffer.n_transitions_stored >= self.min_buffer_size

@@ -65,7 +65,7 @@ def __init__(self,
self.min_buffer_size = min_buffer_size
self.rollout_batch_size = rollout_batch_size
self.reward_scale = reward_scale
self.evaluate = False
self._first_buffer_size_steps_done = False
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This tracks whether the replay buffer is at least min_buffer_size right? So why not just test that directly?

self.replay_buffer.n_transitions_stored >= self.min_buffer_size

Perhaps the original author was concerned about having such a long conditional everywhere? If so, you can add a helper property:

@property
def _buffer_prefilled(self):
    return self.replay_buffer.n_transitions_stored >= self.min_buffer_size

@ryanjulian ryanjulian requested a review from a team January 19, 2020 21:07
@ghost ghost requested review from cbfinn and gitanshu January 19, 2020 21:07
@codecov
Copy link

codecov bot commented Jan 20, 2020

Codecov Report

Merging #1139 into master will increase coverage by 0.01%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #1139      +/-   ##
==========================================
+ Coverage   87.98%   87.99%   +0.01%     
==========================================
  Files         184      184              
  Lines        8780     8771       -9     
  Branches     1108     1108              
==========================================
- Hits         7725     7718       -7     
+ Misses        856      854       -2     
  Partials      199      199
Impacted Files Coverage Δ
src/garage/np/algos/off_policy_rl_algorithm.py 96.77% <100%> (+0.05%) ⬆️
src/garage/tf/algos/ddpg.py 93% <100%> (-0.15%) ⬇️
src/garage/torch/algos/ddpg.py 93.87% <100%> (-0.25%) ⬇️
src/garage/tf/algos/dqn.py 97.77% <100%> (-0.08%) ⬇️
src/garage/misc/tensor_utils.py 93.25% <0%> (+2.24%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update e226e24...ccf70c5. Read the comment docs.

@zequnyu zequnyu requested review from ahtsan and gitanshu and removed request for cbfinn, gitanshu and a team January 20, 2020 01:56
@ryanjulian ryanjulian removed the request for review from gitanshu January 20, 2020 02:07
@ryanjulian
Copy link
Member

@krzentner is this PR still relevant?

- also does duplicate logging removal
@mergify mergify bot merged commit 8394f0c into master Mar 6, 2020
@mergify mergify bot deleted the rename_self_evaluate branch March 6, 2020 23:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants