Rewrite PPO

This commit is contained in:
Shangtong Zhang
2018-04-05 22:32:34 -06:00
parent 8ad31c79b8
commit 549e4af3b8
9 changed files with 162 additions and 120 deletions
+1
View File
@@ -57,3 +57,4 @@ class Config:
self.categorical_n_atoms = 51
self.num_quantiles = 10
self.gaussian_noise_scale = 0.3
self.optimization_epochs = 4
+11
View File
@@ -13,6 +13,17 @@ class Normalizer:
self.n = 1.0
def __call__(self, x):
if np.isscalar(x) or len(x.shape) == 1:
return self.nomalize_single(x)
elif len(x.shape) == 2:
new_x = np.zeros(x.shape)
for i in range(x.shape[0]):
new_x[i] = self.nomalize_single(x[i])
return new_x
else:
assert 'Unsupported Shape'
def nomalize_single(self, x):
is_scalar = np.isscalar(x)
if is_scalar:
x = np.asarray([x])