mirror of
https://github.com/wassname/DeepRL.git
synced 2026-09-09 11:13:47 +08:00
Rewrite PPO
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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])
|
||||
|
||||
Reference in New Issue
Block a user