Skip to content

Commit

Permalink
Merge pull request #1 from jacarvalho/profiling
Browse files Browse the repository at this point in the history
Profiling
  • Loading branch information
jacarvalho committed Feb 1, 2020
2 parents 8059263 + 0263f96 commit 29ea00c
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 7 deletions.
3 changes: 2 additions & 1 deletion .gitignore
@@ -1,4 +1,5 @@
venv/
.idea/
__pycache__/
*.egg-info/
*.egg-info/
quanser/
2 changes: 1 addition & 1 deletion examples/pendulum_nopg_d_behavioral_sampleP.py
Expand Up @@ -65,7 +65,7 @@

nopg = NOPG(dataset, policy, **nopg_params)

n_policy_updates = 1000
n_policy_updates = 50
def optimizer(x): return optim.Adam(x, lr=1e-2)
evaluation_params = {'eval_mdp': mdp,
'eval_every_n': 200,
Expand Down
2 changes: 1 addition & 1 deletion examples/pendulum_nopg_d_uniform.py
Expand Up @@ -65,7 +65,7 @@

nopg = NOPG(dataset, policy, **nopg_params)

n_policy_updates = 1000
n_policy_updates = 50
def optimizer(x): return optim.Adam(x, lr=1e-2)
evaluation_params = {'eval_mdp': mdp,
'eval_every_n': 200,
Expand Down
6 changes: 2 additions & 4 deletions src/nopg/nopg.py
Expand Up @@ -226,17 +226,15 @@ def kernel(X, Y, bandwidth):
@staticmethod
def normalize(X, dim=1):
"""
Normalize X to sum up to 1 along dim.
Normalize X to sum up to 1 along dim, with l1-norm.
:param X: the tensor to normalize
:type X: torch.tensor
:param dim: dimension
:type dim: int
:return: a normalized tensor, summing to 1 along dim
"""
tmp = X / X.sum(dim=dim, keepdim=True)
tmp[torch.isnan(tmp)] = 0.
return tmp
return F.normalize(X, p=1, dim=dim)

def compute_q_mu(self):
"""
Expand Down

0 comments on commit 29ea00c

Please sign in to comment.