I want to train a Sequential Neural Net (NN) with Tensorflow.

bidding_nn = tf.keras.Sequential([
tf.keras.layers.Dense(units=128, activation='elu', kernel_initializer='he_uniform'),
tf.keras.layers.Dense(units=128, activation='elu', kernel_initializer='he_uniform'),
tf.keras.layers.Dense(units=9, activation='softmax', kernel_initializer='he_uniform'),


adam = Adam(lr=0.02, decay=0.01)

bidding_nn.fit(train_dataset, epochs=10)

It should tell me probabilities for the 9 categories I have.

So as input for the NN, I have 8 npArrays of lengths 32 (one-hot encoded) and as output 1 npArray of lengths 9 (one-hot encoded).

(Pdb) train_dataset
<TensorSliceDataset shapes: ((8, 32), (9,)), types: (tf.float64, tf.float64)>

However, at bidding_nn.fit(train_dataset, epochs=10) I get the error message

    ValueError: Shapes (9, 1) and (8, 9) are incompatible

++++++++++++++++++++++ Answer to the problem, see https://stackoverflow.com/a/66350991/12368039

  • $\begingroup$ What line of code did you run to get the ValueError you received? $\endgroup$
    – Oxbowerce
    Feb 24, 2021 at 10:24
  • $\begingroup$ when I call .fit() in here bidding_nn.fit(train_dataset, epochs=10) $\endgroup$
    – Dominik
    Feb 24, 2021 at 10:56
  • $\begingroup$ I got an answer that perfectly fit the problem here stackoverflow.com/a/66350991/12368039 $\endgroup$
    – Dominik
    Feb 24, 2021 at 14:27
  • $\begingroup$ Good to hear, please also add the exact answer that solved your problem for other users who may be getting the same error. $\endgroup$
    – Oxbowerce
    Feb 24, 2021 at 14:33


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.