[RLlib] Implement PPO torch version. (#6826)

This commit is contained in:
Sven Mika
2020-01-20 23:06:50 -08:00
committed by Eric Liang
parent 574abe844a
commit c957ed58ed
25 changed files with 555 additions and 93 deletions
+7 -1
View File
@@ -12,4 +12,10 @@ def explained_variance(y, pred, framework="tf"):
else:
y_var = torch.var(y, dim=[0])
diff_var = torch.var(y - pred, dim=[0])
return max(-1.0, 1 - (diff_var / y_var))
min_ = torch.Tensor([-1.0])
return torch.max(
min_.to(
device=torch.device("cuda")
) if torch.cuda.is_available() else min_,
1 - (diff_var / y_var)
)