tensorflow - 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')
解决方案
编码器
"""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]
)
推荐阅读
- mysql - 使用类似的 MySQL 表,但对于一列的不同 varchar 大小以节省 DB 大小,通过 UNION 查询
- matlab - MATLAB 等高线图可以看起来像 Mathematica 中的吗?
- javascript - 如何从 AJAX 调用向 Spring 控制器发送空日期
- javascript - 如何将两个 xy 数据集与多项式回归相关联?
- hive - 如何在配置单元查询中应用多个计数
- javascript - 将新对象数组添加到特定 id,但它会创建一个新行
- officer - 格式化占位符中的文本
- python - 使用 matplotlib 在一个 python 图中的实线和虚线部分
- node.js - 如何使用 mongoose、nodejs 和 reactjs 在 mongodb 中修复“设置真/假/值而不是 null”
- javascript - 如何允许用户从 Bing 地图打印路线?