-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Working DDQN on mujoco continuous tasks along with parameters
- Loading branch information
Showing
19 changed files
with
147 additions
and
89 deletions.
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
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
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
Binary file not shown.
Binary file not shown.
Binary file not shown.
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
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
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 |
---|---|---|
@@ -1,9 +1,35 @@ | ||
import environments.mujoco.env as mujoco_env | ||
import numpy as np | ||
|
||
|
||
class OrnsteinUhlenbeckActionNoise: | ||
def __init__(self, mu, sigma=0.2, theta=0.15, dt=1e-2, x0=None): | ||
self.theta = theta | ||
self.mu = mu | ||
self.sigma = sigma | ||
self.dt = dt | ||
self.x0 = x0 | ||
self.reset() | ||
|
||
def __call__(self): | ||
x = self.x_prev + self.theta * (self.mu - self.x_prev) * self.dt + \ | ||
self.sigma * np.sqrt(self.dt) * np.random.normal(size=self.mu.shape) | ||
self.x_prev = x | ||
return x | ||
|
||
def reset(self): | ||
self.x_prev = self.x0 if self.x0 is not None else np.zeros_like(self.mu) | ||
|
||
def __repr__(self): | ||
return 'OrnsteinUhlenbeckActionNoise(mu={}, sigma={})'.format(self.mu, self.sigma) | ||
|
||
noise = OrnsteinUhlenbeckActionNoise(mu=np.zeros(2)) | ||
env = mujoco_env.make('speed_task') | ||
obs = env.reset() | ||
while True: | ||
env.render() | ||
obs, _, _, _ = env.step([1, 0.001]) | ||
print(obs) | ||
a = noise() | ||
obs, reward, _, _ = env.step([1, 1]) | ||
print(reward) | ||
# print(obs) | ||
|