Open
Conversation
seba-1511
requested changes
Dec 1, 2020
Member
seba-1511
left a comment
There was a problem hiding this comment.
Hello @MehdiZouitine ,
Thanks for the PR. I've added some comments, mostly about formatting. In addition, could you please add some unit tests for this implementation? (Simple ones, testing for some edge cases.)
I am not familiar with this Dual-Clip PPO, do you have experiments showing its efficacy?
| **References** | ||
|
|
||
| 1. Schulman et al. 2017. “Proximal Policy Optimization Algorithms.” arXiv [cs.LG]. | ||
| 1. Deheng Ye et al. 2020 . “ Mastering Complex Control in MOBA Games with Deep Reinforcement Learning.” arXiv:1912.09729 . |
Member
There was a problem hiding this comment.
Please keep the original reference -- you can add the new one as well.
| **Description** | ||
|
|
||
| The clipped policy loss of Proximal Policy Optimization. | ||
| The dual clipped policy loss of Dual-Clip Proximal Policy Optimization. |
Member
There was a problem hiding this comment.
Please add to the original description, while keeping the original message.
Comment on lines
+115
to
+130
| msg = "new_values, old_values, and rewards must have equal size." | ||
| assert new_values.size() == old_values.size() == rewards.size(), msg | ||
| if debug.IS_DEBUGGING: | ||
| if old_values.requires_grad: | ||
| debug.logger.warning('PPO:state_value_loss: old_values.requires_grad is True.') | ||
| debug.logger.warning( | ||
| "PPO:state_value_loss: old_values.requires_grad is True." | ||
| ) | ||
| if rewards.requires_grad: | ||
| debug.logger.warning('PPO:state_value_loss: rewards.requires_grad is True.') | ||
| debug.logger.warning("PPO:state_value_loss: rewards.requires_grad is True.") | ||
| if not new_values.requires_grad: | ||
| debug.logger.warning('PPO:state_value_loss: new_values.requires_grad is False.') | ||
| loss = (rewards - new_values)**2 | ||
| debug.logger.warning( | ||
| "PPO:state_value_loss: new_values.requires_grad is False." | ||
| ) | ||
| loss = (rewards - new_values) ** 2 | ||
| clipped_values = old_values + (new_values - old_values).clamp(-clip, clip) | ||
| clipped_loss = (rewards - clipped_values)**2 | ||
| clipped_loss = (rewards - clipped_values) ** 2 |
Member
There was a problem hiding this comment.
Those lines shouldn't be modified.
Comment on lines
-53
to
+67
| msg = 'new_log_probs, old_log_probs and advantages must have equal size.' | ||
| assert new_log_probs.size() == old_log_probs.size() == advantages.size(),\ | ||
| msg | ||
| msg = "new_log_probs, old_log_probs and advantages must have equal size." | ||
| assert new_log_probs.size() == old_log_probs.size() == advantages.size(), msg | ||
| if debug.IS_DEBUGGING: | ||
| if old_log_probs.requires_grad: | ||
| debug.logger.warning('PPO:policy_loss: old_log_probs.requires_grad is True.') | ||
| debug.logger.warning( | ||
| "PPO:policy_loss: old_log_probs.requires_grad is True." | ||
| ) | ||
| if advantages.requires_grad: | ||
| debug.logger.warning('PPO:policy_loss: advantages.requires_grad is True.') | ||
| debug.logger.warning("PPO:policy_loss: advantages.requires_grad is True.") | ||
| if not new_log_probs.requires_grad: | ||
| debug.logger.warning('PPO:policy_loss: new_log_probs.requires_grad is False.') | ||
| debug.logger.warning( | ||
| "PPO:policy_loss: new_log_probs.requires_grad is False." | ||
| ) |
Member
There was a problem hiding this comment.
Those lines shouldn't be modified.
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Description
I added a new option in the PPO loss. This option allows to set up the dual clip PPO (https://arxiv.org/pdf/1912.09729.pdf). This option is very important in complex environments (MOBA, Starcraft and multi-agent environments) because trajectories can be sampled from various source of policies.
Contribution Checklist
If your contribution modifies code in the core library (not docs, tests, or examples), please fill the following checklist.