-
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.
- Loading branch information
Showing
18 changed files
with
427 additions
and
594 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
embedding: | ||
pretrain: | ||
steps: 1e5 | ||
epochs: 2500 | ||
optimizer: | ||
lr: 2e-4 | ||
size: 32 | ||
epochs: 1 | ||
batch_size: 2048 | ||
tau: 0.1 | ||
temporal_shift: 4 | ||
spatial_shift: 4 | ||
rollouts_in_batch: 5 | ||
|
||
model: | ||
num_obs: 16 | ||
obs_hidden: 4 | ||
history_fc: 128 | ||
instant_fc: 512 | ||
|
||
agent: | ||
optimizer: | ||
lr: 2e-4 | ||
clip_grad: 1 | ||
pi_clip: 0.1 | ||
gamma: 0.99 | ||
epochs: 3 | ||
batch_size: 256 | ||
ent_k: 0.01 | ||
val_loss_k: 1 | ||
gae_lambda: 0.95 | ||
|
||
train: | ||
max_ep_steps: 108000 | ||
clip_rewards: True | ||
total_steps: 1e7 | ||
rollout_size: 128 | ||
num_env: 8 | ||
log_every: 10 |
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 |
---|---|---|
@@ -0,0 +1,39 @@ | ||
embedding: | ||
pretrain: | ||
steps: 1e5 | ||
epochs: 2500 | ||
optimizer: | ||
lr: 2e-4 | ||
size: 32 | ||
epochs: 1 | ||
batch_size: 2048 | ||
tau: 0.1 | ||
temporal_shift: 4 | ||
spatial_shift: 4 | ||
rollouts_in_batch: 5 | ||
|
||
model: | ||
num_obs: 16 | ||
obs_hidden: 4 | ||
history_fc: 512 | ||
instant_fc: 0 | ||
|
||
agent: | ||
optimizer: | ||
lr: 2e-4 | ||
clip_grad: 1 | ||
pi_clip: 0.1 | ||
gamma: 0.99 | ||
epochs: 3 | ||
batch_size: 256 | ||
ent_k: 0.01 | ||
val_loss_k: 1 | ||
gae_lambda: 0.95 | ||
|
||
train: | ||
max_ep_steps: 108000 | ||
clip_rewards: True | ||
total_steps: 1e7 | ||
rollout_size: 128 | ||
num_env: 8 | ||
log_every: 10 |
This file was deleted.
Oops, something went wrong.
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 was deleted.
Oops, something went wrong.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,50 +1,9 @@ | ||
from typing import List, Dict | ||
import torch | ||
import torch.nn as nn | ||
|
||
|
||
def lerp_nn(source: nn.Module, target: nn.Module, tau: float): | ||
for t, s in zip(target.parameters(), source.parameters()): | ||
t.data.copy_(t.data * (1. - tau) + s.data * tau) | ||
|
||
|
||
def flat_grads(params): | ||
x = [p.grad.data.flatten() for p in params if p.grad is not None] | ||
return torch.cat(x) if len(x) else None | ||
|
||
|
||
def log_grads(model, outp: Dict[str, List[float]]): | ||
for name, net in dict(model.named_children()).items(): | ||
fg = flat_grads(net.parameters()) | ||
if fg is not None: | ||
outp[f'grad/{name}/max'].append(fg.max().item()) | ||
outp[f'grad/{name}/std'].append(fg.std().item()) | ||
|
||
|
||
def onehot(x, num): | ||
r = [1] * (len(x.shape) - 1) + [num] | ||
return torch.zeros_like(x).float().repeat(*r).scatter(-1, x, 1) | ||
|
||
|
||
class Identity(torch.nn.Module): | ||
def forward(self, x): return x | ||
|
||
|
||
class Flatten(nn.Module): | ||
def forward(self, x): return x.view(x.size(0), -1) | ||
|
||
|
||
def init_ortho(module, gain=1): | ||
if isinstance(gain, str): | ||
gain = nn.init.calculate_gain(gain) | ||
nn.init.orthogonal_(module.weight.data, gain=gain) | ||
nn.init.constant_(module.bias.data, 0) | ||
return module | ||
|
||
|
||
def init_ortho_multi(module): | ||
for name, param in module.named_parameters(): | ||
if 'bias' in name: | ||
nn.init.constant_(param, 0) | ||
elif 'weight' in name: | ||
nn.init.orthogonal_(param) |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.