【问题标题】:shape mismatch model InceptionResNetV2 & weigts形状不匹配模型 InceptionResNetV2 和权重
【发布时间】:2019-05-23 14:07:35
【问题描述】:

我正在使用 InceptionResNetV2 进行图像分类并使用相应权重。但得到错误:

ValueError:您正在尝试将包含 449 层的权重文件加载到具有 448 层的模型中。

img_ht = 96
img_wid = 96
img_chnl = 3

import tensorflow as tf
from tensorflow import keras
from keras_preprocessing.image import ImageDataGenerator

train_generator = train_datagen.flow_from_directory(
    directory = "../input/cassava-disease/train/train/",
subset="training",
batch_size = 49,
seed=42,
shuffle=False,
class_mode="categorical",
target_size=(img_ht, img_wid))

valid_generator = train_datagen.flow_from_directory(
directory = "../input/cassava-disease/train/train/",
subset="validation",
batch_size=49,
seed=42,
shuffle=False,
class_mode="categorical",
target_size = (img_ht, img_wid))

from keras.applications import InceptionResNetV2 as InceptionResNetV2

base_model = keras.applications.InceptionResNetV2(input_shape=(img_ht, img_wid, 3), 
                                         include_top = False, 
                                         weights = "../input/inception/inception_resnet_v2_weights_tf_dim_ordering_tf_kernels.h5")

base_model.trainable = False
print(base_model.summary())

【问题讨论】:

    标签: python shapes mismatch


    【解决方案1】:

    得到了答案。这是因为 line --> include_top = False。

    python 和机器学习的新手

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2021-12-13
      • 2018-06-01
      • 2019-06-10
      • 2019-03-05
      • 2016-05-13
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多