if I have two features,
is it necessary to give input_shape in input layer (Dense) ?
or is it fine if I don’t mentioned input_shape in input layer?
if I have two features,
is it necessary to give input_shape in input layer (Dense) ?
or is it fine if I don’t mentioned input_shape in input layer?
Hello @Ranjeet_Kumbhar,
Tensorflow always needs to know the input shape for it to assign the correct number of weights for the model. We can provide that information by (1) adding an Input Layer, (2) specifying it in the first Dense Layer (as you said), or (3) letting Tensorflow discovers the shape when it receives its first batch of samples.
My preference is to specify it with an Input Layer.
Cheers,
Raymond
Thanks for your great suggestion!!
hello again,
Question 1:
i have 2 features
how to mention input_shape.
model_1.add(tf.keras.Input(shape=(2,)))
is it correct?
You need to give a layer
object to model.add(...)
, so please use this one. As for the shape, it is the shape of one sample, so (2, )
is fine.
Btw, I suggest you to try out your idea first, and if you encounter an error, you may share the error message and ask your question here. Trying things out directly is the faster way to know if it works.
Raymond