save normalizer and replay with ddpg agent

This commit is contained in:
Mike C
2018-01-22 10:48:19 +08:00
parent 9318818a97
commit 6a92f52b4f
2 changed files with 27 additions and 1 deletions
+12
View File
@@ -25,6 +25,12 @@ class Normalizer:
o = o.reshape(o_.shape)
return o
def state_dict(self):
return self.stats.state_dict()
def load_state_dict(self, saved):
self.stats.load_state_dict(saved)
class StaticNormalizer:
def __init__(self, o_size):
self.offline_stats = SharedStats(o_size)
@@ -47,6 +53,12 @@ class StaticNormalizer:
o = o.reshape(o_.shape)
return o
def state_dict(self):
return self.offline_stats.state_dict()
def load_state_dict(self, saved):
self.offline_stats.load_state_dict(saved)
class SharedStats:
def __init__(self, o_size):
self.m = torch.zeros(o_size)