Reputation: 386
I have a few Tensorflow models saved as .h5 files.
Due to poor record-keeping and documentation on my part, I can't recall the exact architecture each has. So, I was wondering if there was a way, from the h5 files saved for each model, to inspect the models and determine the architecture.
For example, is there a way to find out the number of layers, the activation functions, input/ouput, size, etc.
Any help is appreciated.
Thanks, Sam
Upvotes: 1
Views: 1734
Reputation:
As suggested by Edwin in comments you can load the model and see the summary for layer details.
You can use the below code to get both the information about activation function and model architecture.
from tensorflow.keras.models import load_model
model = load_model('saved_model.h5')
for layer in model:
try:
print(layer.activation)
#for some layers there will not be any activation fucntion.
except:
pass
#To get the name of layers in the model.
layer_names=[layer.name for layer in model.layers]
#for model's summary and details.
model.summary()
Upvotes: 2