I need to have X[0].shape be (N, 120, 160, 3) which works but i also need X[1].shape = (N, 1, 1) but i only get (N,)
I have tried reshaping it but i didn't manage to make it work.
I am working on a data_generator. I am trying to load inputs from a camera on a car into XY to be able to train a model on it (goal make an self driving car). I am struggling with it.
Here is the part that makes my head hurt.
image_data = {
"image": np.zeros((120, 160, 3), np.float32),
"speed": 3.4,
"throttle": 0.4,
"steering": 0.14,
}
inputs=["image", "speed"]
outputs=["steering", "throttle"]
batch_size = 64
X = []
Y = []
for j in range(len(inputs)):
L = []
for i in range(batch_size):
data = np.array(list(image_data.items()))
L.append(data[j][1])
X.append(np.array(L))
Here is the fix I found, i wasn't shearching for the correct solution.
def __data_generation(self):
X = [[] for _ in range(len(self.inputs))]
Y = [[] for _ in range(len(self.outputs))]
rdm_paths = np.random.choice(self.paths, size=self.batch_size)
for path in rdm_paths:
try:
image_data = io.load_image_data(path)
self.augm(image_data)
for i, inp in enumerate(self.inputs):
data = np.array(image_data[inp])
if len(data.shape) < 2:
data = np.expand_dims(data, axis=0)
X[i].append(data)
for i, out in enumerate(self.outputs):
data = np.array(image_data[out])
if len(data.shape) < 2:
data = np.expand_dims(data, axis=0)
Y[i].append(data)
except Exception:
logging.debug(f"Error processing {path}")
X = [np.array(x) for x in X]
Y = [np.array(y) for y in Y]
return X, Y ```