简体   繁体   English

如何在 Keras - Tensorflow 2.0 中的预训练 InceptionResNetV2 model 的不同层中找到激活的形状

[英]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.

相关问题 如何使用 mmconvert 将 tensorflow 模型(InceptionResnetV2 pb 文件)转换为 pytorch 模型? - How to convert tensorflow model (InceptionResnetV2 pb file) to pytorch model using mmconvert? 类型错误:“模块”object 在 InceptionResNetV2 Keras 中不可调用 - TypeError: 'module' object is not callable in InceptionResNetV2 Keras 为 keras inceptionresnetv2 寻找层名称 - Looking for layer names for keras inceptionresnetv2 形状不匹配模型InceptionResNetV2&weigts - shape mismatch model InceptionResNetV2 & weigts 如何在keras的功能性api中向预训练模型的底部添加图层? - How to add layers to the bottom of a pretrained model in keras' functional api? 是否可以用 2D 灰度图像提供预训练的 Inception model(tensorflow 2.0/Keras)? - Is it possible to feed the pretrained Inception model (tensorflow 2.0/Keras) with 2D grayscale images? tensorflow.keras model 具有多个不同形状的输入(错误) - tensorflow.keras model with multiple inputs with different shapes (Error) TensorFlow、Keras:替换预训练 model 中的激活层 - TensorFlow, Keras: Replace Activation layer in pretrained model 如何修复“ModuleNotFoundError:没有名为'keras.layers.advanced_activations'的模块” - How to fix "ModuleNotFoundError: No module named 'keras.layers.advanced_activations' " 如何使用预训练的 model 的第一层来提取 Keras model 内部的特征(功能 API) - How to use the first layers of a pretrained model to extract features inside a Keras model (Functional API)
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM