MCPcopy Create free account
hub / github.com/ChristopherLu/milliEgo / load_data_multi_timestamp

Function load_data_multi_timestamp

utility/data_loader.py:132–182  ·  view source on GitHub ↗
(training_file, sensor)

Source from the content-addressed store, hash-verified

130
131
132def load_data_multi_timestamp(training_file, sensor):
133
134 # Load data
135 x_sensor, x_imu, y = [], [], []
136 hdf5_file = h5py.File(training_file, 'r')
137 x_time = hdf5_file.get('timestamp')
138 x_sensor_temp = hdf5_file.get(sensor+'_data')
139 x_imu_temp = hdf5_file.get('imu_data')
140 y_temp = hdf5_file.get('label_data')
141
142
143 print('Data shape: ' + str(np.shape(x_sensor_temp)))
144
145 # this is for raw data
146 if x_sensor_temp.shape[0] == 1:
147 x_sensor_temp = x_sensor_temp[0]
148
149 if x_imu_temp.shape[0] == 1:
150 x_imu_temp = x_imu_temp[0]
151 y_temp = y_temp[0]
152
153 print('Data shape: ' + str(np.shape(x_sensor_temp)) + str(str(np.shape(y_temp))))
154
155 data_size = np.size(x_sensor_temp, axis=0)
156
157 # Determine whether the data should be divided into several chunks
158 # to fit in memory
159 data_per_chunk = 5000
160 is_special_case = False
161 if data_size > 10000:
162 n_chunk = data_size // data_per_chunk
163 n_chunk += 1
164 is_special_case = True
165 else:
166 n_chunk = 1
167
168 if is_special_case == True:
169 # Divide into several chunks if the length of the data is too large
170 for i in range(n_chunk-1):
171 x_sensor.append(x_sensor_temp[(data_per_chunk * i):data_per_chunk * (i + 1), :, :, :])
172 x_imu.append(x_imu_temp[(data_per_chunk * i):data_per_chunk * (i + 1), :, :, :])
173 y.append(y_temp[(data_per_chunk * i):data_per_chunk * (i + 1), :])
174
175 x_sensor.append(x_sensor_temp[(data_size - data_per_chunk):data_size, :, :, :])
176 x_imu.append(x_imu_temp[(data_size - data_per_chunk):data_size, :, :, :])
177 y.append(y_temp[(data_size - data_per_chunk):(data_size-1), :])
178 else:
179 x_sensor.append(x_sensor_temp[0:data_size, :, :, :])
180 x_imu.append(x_imu_temp[0:data_size, :, :])
181 y.append(y_temp[0:(data_size-1), :])
182 return n_chunk, x_time, x_sensor, x_imu, y
183
184def load_data_single_sensor(training_file, sensor):
185 # Load data

Callers 1

mainFunction · 0.90

Calls

no outgoing calls

Tested by 1

mainFunction · 0.72