mirror of
https://github.com/wassname/DeepRL.git
synced 2026-09-09 11:13:47 +08:00
Update video prediction
This commit is contained in:
+23
-1
@@ -61,4 +61,26 @@ def sync_grad(target_network, src_network):
|
||||
|
||||
def mkdir(path):
|
||||
if not os.path.exists(path):
|
||||
os.mkdir(path)
|
||||
os.mkdir(path)
|
||||
|
||||
class Batcher:
|
||||
def __init__(self, batch_size, data):
|
||||
self.batch_size = batch_size
|
||||
self.data = data
|
||||
self.num_entries = len(data[0])
|
||||
self.reset()
|
||||
|
||||
def reset(self):
|
||||
self.batch_start = 0
|
||||
self.batch_end = self.batch_start + self.batch_size
|
||||
|
||||
def end(self):
|
||||
return self.batch_start >= self.num_entries
|
||||
|
||||
def next_batch(self):
|
||||
batch = []
|
||||
for d in self.data:
|
||||
batch.append(d[self.batch_start: self.batch_end])
|
||||
self.batch_start = self.batch_end
|
||||
self.batch_end = min(self.batch_start + self.batch_size, self.num_entries)
|
||||
return batch
|
||||
|
||||
Reference in New Issue
Block a user