I have this tensor of multidimensional array:
# read from memory-mapped files
# File paths for memory-mapped files
input_file_path = 'tensor_input.dat'
output_file_path = 'tensor_output.dat'
# Define the shapes of the arrays
tensor_input_shape = (12, 5, 120, 2, 600, 600) # num of ID, num of channels, timeline, timesteps, height, width
tensor_output_shape = (12,) # num of ID
tensor_input = np.memmap(input_file_path, dtype='uint8', mode='r', shape=tensor_input_shape)
# Debugging outputs
dbg(tensor_input)
Outputting:
tensor type is numpy array
shape: (12, 5, 120, 2, 600, 600)
dtype: uint8
The tensor input size is so large, that’s why I use mmap.
The ConvLSTM2D
keras accept 5D (batch, timestep, height, width, channel). Therefore I expect I can reshape the mmap into (batch*timeline, timestep, height, width, channel).
I can swap or change axis with np.transpose
. But I’m afraid if I messed up the memory structure, mainly there is flatenned axis at batch and timeline axis.