Skip to content

Instantly share code, notes, and snippets.

@jangirrishabh
Last active July 13, 2018 13:25
Show Gist options
  • Save jangirrishabh/bf6f7b5695826fa909aa0bcd85e67e9f to your computer and use it in GitHub Desktop.
Save jangirrishabh/bf6f7b5695826fa909aa0bcd85e67e9f to your computer and use it in GitHub Desktop.
Snippet for using demonstrations in ddpg.py agent, blog usage, not executable
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