Search code examples
pythonnumpyh5pypre-trained-modeltransfer-learning

How to find the number of layers from the saved h5 file of pre-trained model?


I have VGG-16 weights saved in h5 format. I want to see the number of layers in the network. How can I do that?

I tried using:

file = h5py.File(vgg16.h5)

after that, I checked for file.attrs but after this point I don't know which command to use to find the number of layers in the network.


Solution

  • If you type this code in spyder provided, you have installed Keras library. You will get all the layers in h5.file

    from keras.models import load_model
    
    classifier=load_model('my_model.h5')
    
    classifier.summary()