Reputation: 147
I am trying to build a Tensorflow simple AI and I don't understand where my problem is when I compare it to various articles I read about this topic.
I have two numpy arrays made for training of sizes (N,1) (what should be predicted) and (N,3) (what are the inputs that should be predicted), and I want my algorithm to predict with Input[0,i] Input[1,i] Input[2,i] the value of ToPredict[i] (the i-th sample). I thought I had to use tf.data.Dataset.from_tensor_slices and then
modele = tf.keras.Sequential([ tf.keras.layers.Flatten(), tf.keras.layers.Dense(128, activation='relu'), tf.keras.layers.Dense(1) ])
modele.compile(optimizer=tf.keras.optimizers.RMSprop(), loss=tf.keras.losses.SparseCategoricalCrossentropy(), metrics=['sparse_categorical_accuracy'])
modele.fit(A, epochs=10)
When I do that, I get the following error:
logits and labels must have the same first dimension, got logits shape [3,10] and labels shape [1] [[node loss_9/output_1_loss/SparseSoftmaxCrossEntropyWithLogits/SparseSoftmaxCrossEntropyWithLogits (defined at :11) ]] [Op:__inference_keras_scratch_graph_2640]
So I know that there is a shape error, but I don't know how to tell the algorithm what I want as shapes.
Could anyone help me? Also yes I have seen related stackoverflow posts but they don't seem to solve my issue.
Upvotes: 0
Views: 220