是否可以创建同一CNN的多个实例,这些实例吸收多个图像并串联成一个密集层? (喀拉拉邦)

类似于this question,我希望有多个图像输入层通过一个较大的cnn(例如XCeption减去密集层),然后将所有图像中一个cnn的输出串联在一起致密的层。

是否可以创建同一CNN的多个实例,这些实例吸收多个图像并串联成一个密集层? (喀拉拉邦)

使用Keras能否做到这一点,或者甚至有可能使用这种架构从头开始训练网络?

我本质上是在寻找一种训练模型,该模型可以在每个样本中获取更大但固定数量的图像(即具有类似视觉特征的3个以上的图像输入),而不是通过一次训练多个cnn来爆炸参数数量。这个想法是只训练一个cnn,该cnn可用于所有输出。将所有图像放入相同的密集层非常重要,因此该模型可以了解多个图像之间的关联,这些关联始终根据其来源进行排序。

yifeichongtian1234 回答:是否可以创建同一CNN的多个实例,这些实例吸收多个图像并串联成一个密集层? (喀拉拉邦)

您可以通过以下方式使用Keras功能API轻松实现此目标。

from tensorflow.python.keras import layers,models,applications

# Multiple inputs
in1 = layers.Input(shape=(128,128,3))
in2 = layers.Input(shape=(128,3))
in3 = layers.Input(shape=(128,3))

# CNN output
cnn = applications.xception.Xception(include_top=False)


out1 = cnn(in1)
out2 = cnn(in2)
out3 = cnn(in3)

# Flattening the output for the dense layer
fout1 = layers.Flatten()(out1)
fout2 = layers.Flatten()(out2)
fout3 = layers.Flatten()(out3)

# Getting the dense output
dense = layers.Dense(100,activation='softmax')

dout1 = dense(fout1)
dout2 = dense(fout2)
dout3 = dense(fout3)

# Concatenating the final output
out = layers.Concatenate(axis=-1)([dout1,dout2,dout3])

# Creating the model
model = models.Model(inputs=[in1,in2,in3],outputs=out)
model.summary()```
本文链接:https://www.f2er.com/3126769.html

大家都在问