Last active
July 13, 2018 13:25
-
-
Save jangirrishabh/bf6f7b5695826fa909aa0bcd85e67e9f to your computer and use it in GitHub Desktop.
Snippet for using demonstrations in ddpg.py agent, blog usage, not executable
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
self.demo_batch_size = 128 | |
def initDemoBuffer(self, demoDataFile, update_stats=True): | |
#To initiaze the demobuffer with the recorded demonstration data. We also normalize the demo data. | |
def sample_batch(self): | |
if self.bc_loss: | |
transitions = self.buffer.sample(self.batch_size - self.demo_batch_size) | |
global demoBuffer | |
transitionsDemo = demoBuffer.sample(self.demo_batch_size) | |
for k, values in transitionsDemo.items(): | |
rolloutV = transitions[k].tolist() | |
for v in values: | |
rolloutV.append(v.tolist()) | |
transitions[k] = np.array(rolloutV) | |
else: | |
transitions = self.buffer.sample(self.batch_size) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment