I have a problem which deals with figuring out existence of specific lines in an image. as input - i have a 96*54 binary image, as output i have 18 numbers with either 1 or 0.
when i tried to create multiple outputs, after fitting i got the following error: The model expects 18 target arrays, but only received one array. I tried experimenting with reshaping the output tenzor in many ways, even using the python array to hold np tenzors, but no success.
here is the code:
main_input = Input(shape=(54,96,1))
x = Conv2D(16,kernel_size=(3,3),activation='relu')(main_input)
x = MaxPooling2D(pool_size=(2,2))(x)
x = Conv2D(32,kernel_size=(3,3),activation='relu')(x)
x = MaxPooling2D(pool_size=(2,2))(x)
x = Conv2D(64,(3,3),activation='relu')(x)
x = MaxPooling2D(pool_size=(2,2))(x)
x = Conv2D(128,(3,3),activation='relu')(x)
x = Flatten()(x)
x = Dense(256,activation='relu')(x)
out = [Dense(1,activation='softmax')(x)] * 18
y_train_split = np.asarray([y_train[:,i] for i in range(18)])
model = Model(inputs=main_input, outputs=out)
model.compile(loss=keras.losses.binary_crossentropy, optimizer=keras.optimizers.Adadelta(),metrics=['accuracy'])
model.fit(x_train, y_train_split, batch_size=batch_size, epochs=epochs,verbose=1,validation_data = (x_test,y_test))
score = model.evaluate(x_eval,y_eval,verbose=0)