首页 > 解决方案 > ResNet 和 ConvNet 的结合

问题描述

我准备了一个用于图像着色的 CNN 模型:

"""Encoder - Input grayscale image (L)"""
model = Sequential()
model.add(Conv2D(32, (3, 3), activation='relu', padding='same', input_shape=(256, 256, 1)))

...

"""Latent space"""
model.add(Conv2D(512, (3,3), activation='relu', padding='same'))

"""Decoder - output (A,B)"""

...

model.add(Conv2D(2, (3, 3), activation='tanh', padding='same'))

现在我想使用 ResNet 作为特征提取器并将输出合并到潜在空间。

我已经将 ResNet 模型导入为:

resnet50_imagnet_model = tf.keras.applications.resnet.ResNet50(weights = "imagenet", 
                           include_top=False, 
                           input_shape = (256, 256, 3),
                           pooling='max')

标签: tensorflowkerasresnet

解决方案


编码器

"""Encoder - Input grayscale image (L)"""
encoder = Sequential()
model.add(Conv2D(32, (3, 3), activation='relu', padding='same', input_shape=(256, 256, 1)))

...

解码器

decoder = """Decoder - output (A,B)"""

...

用于tf.keras.Sequential()合并所有模型

comb_model = tf.keras.Sequential(
    [encoder,resnet50_imagnet_model, decoder]
)

推荐阅读