I want to visualize my neural net. Therefore, I use from tensorflow.keras.utils import plot_model
and use it like this:
model = Sequential()
model.add(Dense(8, activation="relu"))
model.add(Dense(1))
plot_model(model, to_file="model.png", show_shapes=True)
But, when I open the graphic, it looks like this:
What is wrong with my code? I do not see any error.
The reason is that the model has not been built because it does not know its input shape. Either specify the input shape of the model on the first layer using input_shape
(or input_dim
) argument, or alternatively start fitting the model on some data by calling fit
method (so the input shape could be automatically inferred). Also, as mentioned by @xdurch0 in the comments section, another option is to call build
method of the model and pass it the input shape as argument.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With