def __init__(self, tensors, up_label="up", right_label="right",
down_label="down", left_label="left",
copy_data=True):
self.up_label = up_label
self.right_label = right_label
self.down_label = down_label
self.left_label = left_label
if copy_data:
# Creates copies of tensors in memory
copied_tensors = []
for row in tensors:
copied_tensors.append([x.copy() for x in row])
self.data = np.array(copied_tensors)
else:
# This will not create copies of tensors in memory
# (just link to originals)
self.data = np.array(tensors)
# Every tensor will have four indices corresponding to
# "left", "right" and "up", "down" labels.
for i, x in np.ndenumerate(self.data):
if left_label not in x.labels: x.add_dummy_index(left_label)
if right_label not in x.labels: x.add_dummy_index(right_label)
if up_label not in x.labels: x.add_dummy_index(up_label)
if down_label not in x.labels: x.add_dummy_index(down_label)
# Add container emulation
评论列表
文章目录