I have a model using Keras Functional API with 2 outputs: (CNN and regression) model with 2 outputs:
trying to use predict but getting ValueError: could not broadcast input array from shape (75,11) into shape (75,)
here's the code of training process:
fold_no = 1
kfold = KFold(n_splits=num_folds, shuffle=True)
for tr, valid in kfold.split(train_images, train_labels):
print('------------------------------------------------------------------------')
print(f'Training for fold {fold_no} ...')
# Train the model
history= model.fit(data_images[tr], data_vector[tr],
batch_size=batch_size,
epochs=80,
verbose=verbosity,
validation_split=0.2)
scores = model.evaluate(data_images[valid], data_vector[valid], verbose=0)
print(data_labels[valid])
print(np.argmax(model.predict(data_images[valid]), axis=-1))
fold_no += 1
printed the shape of:
Please any suggestions to solve this problem will be helpful, I need a way to take results from the trained model. thanks in advance
I found the reason for the error:
predict for 2 outputs model returns an array with the results of prediction for both model outputs.
to reach one of them can use an index, in my example:
model.predict(data_images)[0]
for classification
and model.predict(data_images)[1]
for regression