[英]How to find the shapes of activations in the different layers of a pretrained InceptionResNetV2 model in Keras - Tensorflow 2.0
I have load the inceptionResNetV2 Keras model我已经加载了 inceptionResNetV2 Keras model
base_model = tf.keras.applications.inception_resnet_v2.InceptionResNetV2(include_top=False, weights='imagenet')
I want to find the shapes of the activations outputed by different layers -- assuming a standard input size of (299x299).我想找到不同层输出的激活的形状——假设标准输入大小为(299x299)。
My ultimate goal is to make an informed decision on what part of the pre-trained model to retain untrained (using also other criteria).我的最终目标是就预先训练的 model 的哪些部分保留未经训练的部分(也使用其他标准)做出明智的决定。
I tried:我试过了:
base_model.summary()
Which returns:返回:
Similarly when I try:同样,当我尝试:
In other words I am getting the depth (number of filters) of the activation tensor but not the Width/Height.换句话说,我得到的是激活张量的深度(滤波器数量),而不是宽度/高度。
What should I do to find the shape of activations once I input a (299x299) image to the network?将 (299x299) 图像输入网络后,我应该怎么做才能找到激活的形状?
You can put the input_shape
in the function by您可以将
input_shape
放入 function 通过
base_model = tf.keras.applications.inception_resnet_v2.InceptionResNetV2(include_top=False, weights='imagenet', input_shape=(299, 299, 3))
But this will raise an error if input images aren't 299*299 so better use it only when you want to know the shape.但是,如果输入图像不是 299*299,这将引发错误,因此最好仅在您想知道形状时使用它。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.