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

Modify hidden activation #317

Merged
merged 1 commit into from
Aug 19, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions configs/lunarlander_continuous_v2/ppo.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ learner_cfg:
type: "GaussianDist"
configs:
hidden_sizes: [256, 256]
hidden_activation: "tanh"
output_activation: "identity"
fixed_logstd: True
critic:
Expand Down
5 changes: 5 additions & 0 deletions rl_algorithms/common/helper_functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,11 @@ def identity(x: torch.Tensor) -> torch.Tensor:
return x


def relu(x: torch.Tensor) -> torch.Tensor:
"""Return torch.relu(x)"""
return torch.relu(x)


def soft_update(local: nn.Module, target: nn.Module, tau: float):
"""Soft-update: target = tau*local + (1-tau)*target."""
for t_param, l_param in zip(target.parameters(), local.parameters()):
Expand Down
6 changes: 5 additions & 1 deletion rl_algorithms/common/networks/heads.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,11 @@ def __init__(
self.hidden_sizes = configs.hidden_sizes
self.input_size = configs.input_size
self.output_size = configs.output_size
self.hidden_activation = hidden_activation
self.hidden_activation = (
getattr(helper_functions, configs.hidden_activation)
if "hidden_activation" in configs.keys()
else hidden_activation
)
self.output_activation = getattr(helper_functions, configs.output_activation)
self.linear_layer = linear_layer
self.use_output_layer = use_output_layer
Expand Down