* Add td3

* Fix flake8

* Fix action clamping

* Increase episode max step, add detach to actor_loss

* Fix actor update freq bug

* Add per (#8)

* Add per and modify etc

* Replace pre-commit-config.yaml and add pre-commit hook in .git

* Modify .gitignore

* Modify .gitignore

* Modify buffer and code

* Modify replay buffer and per

* Modify .gitignore

* Add random initial action in ddpg (#13)

* Add random initial actions in ddpg

* Add reacher-v2 example of ddpg

* Add soft actor critic (#12)

* Add soft actor critic

* Delete unnecessary examples

* Add td3

* Fix flake8

* Fix action clamping

* Fix flake8

* Increase episode max step, add detach to actor_loss

* Fix actor update freq bug

* Fix code to reflect PR

* Resolve conflict
This commit is contained in:
Whi Kwon
2019-02-24 13:44:20 +09:00
committed by GitHub
parent 4a19053d25
commit 5962ff5277
3 changed files with 402 additions and 3 deletions
+5 -3
View File
@@ -15,21 +15,23 @@ class GaussianNoise:
def __init__(
self,
action_dim: int,
min_sigma: float = 1.0,
max_sigma: float = 1.0,
decay_period: int = 1000000,
):
"""Initialization."""
self.max_sigma = max_sigma
self.action_dim = action_dim
self.min_sigma = min_sigma
self.max_sigma = max_sigma
self.decay_period = decay_period
def sample(self, action_size: int, t: int = 0) -> float:
def sample(self, t: int = 0) -> float:
"""Get an action with gaussian noise."""
sigma = self.max_sigma - (self.max_sigma - self.min_sigma) * min(
1.0, t / self.decay_period
)
return np.random.normal(0, sigma, size=action_size)
return np.random.normal(0, sigma, size=self.action_dim)
class OUNoise: