Reputation: 19
I'm new to this and still learning about how to build a simple BiLSTM model for my time series prediction, i somehow manage to create one and now i want to convert the model summary into a png file.
Here is my code
from tensorflow.keras.models import Sequential
model_opendf=Sequential()
model_opendf.add(Bidirectional(LSTM(100, activation='relu', input_shape=(100,1))))
model_opendf.add(Dense(1))
model_opendf.compile(loss="mean_squared_error", optimizer="adam")
from keras.utils.vis_utils import plot_model
model_opendf.build(input_shape=(100,1))
model_opendf.summary()
plot_model(model_opendf, to_file='lstm_model.jpg')
the result is like this
It feels empty, is there anything else that i can use to populate with plot_model? and how to convert the image instantly into png?
Upvotes: 0
Views: 1575
Reputation: 919
In tensorflow version 2.15, I had to use keras.utils to make it work like following and I did install pip install pydot
and brew install graphviz
as well
from keras.utils import plot_model
plot_model(model, to_file='model.png', show_shapes=True, show_layer_names=True)
Upvotes: 0
Reputation: 26
Here is a reference link for plot_model, you can add show_shapes and show_layer_names like this:
from keras.utils.vis_utils import plot_model
model_opendf.build(input_shape=(100,1))
model_opendf.summary()
plot_model(model_opendf, to_file='lstm_model.png', show_shapes=True, show_layer_names=True)
And if you want to convert the output from jpg to png, or any other image file, you can just type the image format you want in this case, change it from jpg to png.
Your model should looks like this:
Upvotes: 1