I want to build a Neural Network with two inputs: for image data and for numeric data. So I wrote custom data generator for that. The train
and validation
You need to convert all the individual objects returned by both the training and validation generators to Numpy arrays:
yield [np.array(imgs), np.array(cols)], np.array(targets)
Alternatively, a simpler and much more efficient solution is to not iterate over the data batch at all; instead, we can take advantage of the fact that these objects are already Numpy arrays when returned by ImageDataGenerator
, so we can write:
imgs = data[0]
cols = data[1][:,:-1]
targets = data[1][:,-1:]
yield [imgs, cols], targets