I am trying to create a neural network model with one hidden layer and then trying to evaluate it, but I am getting an error that I am not able to understand clearly:
ValueError: Input 0 of layer sequential_1 is incompatible with the layer: : expected min_ndim=2, found ndim=1. Full shape received: [30]
It looks like I have an error with the dimensions of my input layer, but I can't quite spot what. I've googled and looked on stackoverflow, but haven't found anything that worked so far. Any help please?
Here's a minimal working example:
import tensorflow as tf
# Define Sequential model with 3 layers
input_dim = 30
num_neurons = 10
output_dim = 12
model = tf.keras.Sequential(
[
tf.keras.layers.Dense(input_dim, activation="relu", name="layer1"),
tf.keras.layers.Dense(num_neurons, activation="relu", name="layer2"),
tf.keras.layers.Dense(output_dim, name="layer3"),
]
)
model(tf.ones(input_dim))