【问题标题】:How to find the shapes of activations in the different layers of a pretrained InceptionResNetV2 model in Keras - Tensorflow 2.0如何在 Keras 中的预训练 InceptionResNetV2 模型的不同层中找到激活的形状 - Tensorflow 2.0
【发布时间】:2020-02-06 13:37:09
【问题描述】:

我已经加载了 inceptionResNetV2 Keras 模型

base_model = tf.keras.applications.inception_resnet_v2.InceptionResNetV2(include_top=False, weights='imagenet')

我想找到不同层输出的激活的形状——假设标准输入大小为 (299x299)。

我的最终目标是就预训练模型的哪些部分保留未经训练的部分做出明智的决定(也使用其他标准)。

我试过了:

base_model.summary()

返回:

当我尝试时也是这样:

换句话说,我得到的是激活张量的深度(过滤器数量),而不是宽度/高度。

将 (299x299) 图像输入网络后,我应该怎么做才能找到激活的形状?

【问题讨论】:

    标签: python tensorflow keras shapes activation


    【解决方案1】:

    你可以把input_shape放在函数中

    base_model = tf.keras.applications.inception_resnet_v2.InceptionResNetV2(include_top=False, weights='imagenet', input_shape=(299, 299, 3))
    

    但是如果输入图像不是 299*299,这会引发错误,因此最好仅在您想知道形状时使用它。

    【讨论】:

      猜你喜欢
      • 2021-05-20
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-01-20
      • 2020-06-13
      • 2020-02-06
      • 1970-01-01
      • 2017-05-29
      相关资源
      最近更新 更多