need help with creating model in tensorflow [closed]

asked 2021-09-14 14:34:06 -0500

PGTKing gravatar image

updated 2021-09-15 02:05:19 -0500

gvdhoorn gravatar image

Here is the model I am using

model = tf.keras.Sequential([
    tf.keras.layers.Flatten(input_shape=(1,)),
    tf.keras.layers.Dense(128, activation='relu'),
    tf.keras.layers.Dense(25,)
])
model.compile(loss="categorical_crossentropy", optimizer="adam", metrics="accuracy")
return model

my input layer is shaped like this

[0.46981431 0.32957182 0.6432879 ]

and my output layer is shaped like this

[[0. 0. 0. 0. 1. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0.
  0.]
 [0. 0. 0. 0. 1. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0.
  0.]
 [0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 1.
  0.]]

The error I am having is

ValueError: Input 0 of layer sequential is incompatible with the layer: expected axis -1 of input shape to have value 1 but received input with shape (None, 25)

I don't understand what this means

edit retag flag offensive reopen merge delete

Closed for the following reason question is off-topic or not relevant. Please see http://wiki.ros.org/Support for more details. by gvdhoorn
close date 2021-09-15 02:04:29.513206

Comments

I'm sorry, but this is not a ROS question. It's purely something about TensorFlow.

Please post your question on a more appropriate forum.

gvdhoorn gravatar image gvdhoorn  ( 2021-09-15 02:04:56 -0500 )edit

I know this is not the right place. @PGTKing Consider it as a hint.

Just to note: Your input data shape(3 shape which is "[0.46981431 0.32957182 0.6432879 ]") and your model shape do not match (Flatten with 1 shape). This both should be same.

Ranjit Kathiriya gravatar image Ranjit Kathiriya  ( 2021-09-15 06:05:15 -0500 )edit