Reputation: 1
I use efficientnetv2 from hub.KerasLayer
, I would like to see all layers when using model.summary()
, but it shows only "keras_layer (KerasLayer)"
Layer (type) | Output Shape | Param # |
---|---|---|
keras_layer (KerasLayer) | (None, 1280) | 5919312 |
dropout (Dropout) | (None, 1280) | 0 |
dense (Dense) | (None, 2) | 2562 |
Upvotes: 0
Views: 2306
Reputation: 721
TensorFlow's SavedModel is essentially a computation graph. While you could in principle inspect its structure, there is no information about high-level architectural blocks.
If you'd like to access individual layers, a better option might be using the model from the authors' original implementation. It can be constructed as follows:
from effnetv2_model import get_model
model = get_model('efficientnetv2-s', weights='imagenet21k-ft1k', with_endpoints=True)
Pretrained weights are available for the same configurations as in TensorFlow Hub. model.summary()
displays individual (Fused)MBConv blocks.
Also note that a future version of TensorFlow will include EfficientNet v2 (already available in nightly builds).
Upvotes: 0
Reputation: 419
This way you can "jump inside" the model;
import tensorflow_hub as hub
malli = hub.KerasLayer("https://tfhub.dev/google/imagenet/efficientnet_v2_imagenet21k_b0/feature_vector/2")
print("Thickness of the model:", len(malli.weights))
for i in range(len(malli.weights)):
print("In layer ",malli.weights[i].name," the content is: ", malli.weights[i])
...of course note the output is quite a loooong but modify the output print according to your need.
Upvotes: 1