Skip to content
Advertisement

Keras tuner Bayesian Optmization graph error

I am trying to optimize a convolutional neural network with Bayesian Optimization algorithm provided in keras tuner library.

When I perform the line: tuner_cnn.search(datagen.flow(X_trainRusReshaped,Y_trainRusHot), epochs=50, batch_size=256) I encounter this error: InvalidArgumentError: Graph execution error

One-Hot-Encode y_train and y_test as the following:

JavaScript

I defined my model builder like that:

JavaScript

perform the tuner search:

JavaScript

I also tried to do:

JavaScript

But it does not work neither. Any idea?

Advertisement

Answer

From the full error message I was able to narrow down where the issue is coming from. The issue is that your last Dense layer has 10 units, which means you expect 10 classes (you even chose the correct activation function given the number of units). However you have Binary CrossEntropy as loss.

So you either have 10 classes and use either categorical or sparse categorical CrossEntropy or you have 2 classes and so the loss is indeed Binary CrossEntropy.

User contributions licensed under: CC BY-SA
2 People found this is helpful
Advertisement