首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >形状失配模型InceptionResNetV2 & weigts

形状失配模型InceptionResNetV2 & weigts
EN

Stack Overflow用户
提问于 2019-05-23 14:07:35
回答 1查看 38关注 0票数 0

我使用InceptionResNetV2进行图像分类&使用回复权重。但要犯错误:

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

代码语言:javascript
复制
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())
EN

回答 1

Stack Overflow用户

发布于 2019-05-24 11:08:47

找到答案了。这是因为行-> include_top = False。

python &机器学习的新技术

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/56277092

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档