【发布时间】:2019-02-01 04:48:38
【问题描述】:
我在 Keras 中使用 Inception 模型和图像网络的预训练权重。
问题在于,根据 Keras 文档,此模型的默认输入大小为 299x299。虽然我的图像是 230 * 350,但我不想调整它们的大小,因为它会扭曲图像。所以我试图找到一种方法来改变输入层的大小。
下面是我迄今为止尝试过的代码,但是我怀疑图像净重是否被保留,因为我认为当我改变输入大小时架构会改变。
任何想法..
input = Input(shape=(230, 350, 3), name='image_input')
base_model = InceptionV3(weights='imagenet', include_top=False, input_tensor=input)
x = base_model.output
x = GlobalAveragePooling2D()(x)
x = Dense(64, activation='relu')(x)
predictions = Dense(1, activation='sigmoid')(x)
model = Model(inputs=input, outputs=predictions)
for layer in base_model.layers:
layer.trainable = True
model.compile(loss='binary_crossentropy',
optimizer=Adam(lr=0.0001),
metrics=['accuracy'])
【问题讨论】:
-
不幸的是我不能做作物,因为它是一个医学图像数据集(用于癌症)。如果我裁剪图像,我可能会丢失其中包含癌细胞的部分。
标签: python keras deep-learning conv-neural-network