-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathhistory.py
More file actions
31 lines (25 loc) · 709 Bytes
/
Copy pathhistory.py
File metadata and controls
31 lines (25 loc) · 709 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
import numpy as np
class History(object):
def __init__(
self,
data_format,
batch_size,
history_length,
screen_height,
screen_width
):
self.data_format = data_format
batch_size, history_length, screen_height, screen_width = \
batch_size, history_length, screen_height, screen_width
self.history = np.zeros(
[history_length, screen_height, screen_width], dtype=np.float32)
def add(self, screen):
self.history[:-1] = self.history[1:]
self.history[-1] = screen
def reset(self):
self.history *= 0
def get(self):
if self.data_format == 'NHWC':
return np.transpose(self.history, (1, 2, 0))
else:
return self.history