【发布时间】:2020-06-24 13:21:43
【问题描述】:
我有两种类型的数据 - 带有标签的表数据集和图像集。 我正在构建一个回归模型和一个将连接的 CNN 模型。这个想法是,通过训练 CNN,我将提取更多特征,这将有助于回归模型。 但是我从来没有建立过这样的模型,也不知道如何在 model.fit 部分中给它数据。我有两对数据:
- train_x、train_y 来自表数据集,以及
- img_train_x 来自图像数据集(我当然也有测试数据)。 因此,model.fit 只接受两个变量 - X、y。我不知道将图像中的数据放在哪里。
这是我的模型:
inputs1 = Input(shape = (1,52,53))
model1 = Conv2D(filters = 32, kernel_size=5, padding = 'same', activation='relu')(inputs)
model1 = BatchNormalization()(model1)
model1 = MaxPool2D(pool_size = (2,2), data_format='channels_first')(model1)
model1 = Conv2D(filters = 32, kernel_size=5, padding = 'same', activation='relu')(inputs)
model1 = BatchNormalization()(model1)
model1 = MaxPool2D(pool_size = (2,2), data_format='channels_first')(model1)
model1 = Conv2D(filters = 64, kernel_size=5, padding = 'same', activation='relu')(inputs)
model1 = BatchNormalization()(model1)
model1 = MaxPool2D(pool_size = (2,2), data_format='channels_first')(model1)
model1 = Conv2D(filters = 128, kernel_size=5, padding = 'same', activation='relu')(inputs)
model1 = BatchNormalization()(model1)
model1 = MaxPool2D(pool_size = (2,2), data_format='channels_first')(model1)
flatten = Flatten()(model1)
inputs2 = Input(shape = (1404,))
model2 = Dense(1404, activation='relu')(inputs2)
model2 = Dropout(0.25)(model2)
model2 = Dense(702, activation = 'relu')(model2)
model2 = Dropout(0.25)(model2)
model2 = Dense(702, activation = 'relu')(model2)
model2 = Dropout(0.25)(model2)
model2 = Dense(351, activation = 'relu')(model2)
concat = Concatenate()([flatten, model2])
outputs = Dense(num_regr_outputs)(concat)
我会很感激这里的帮助。
【问题讨论】:
-
初始图像的形状是什么? (1, 52, 53)...黑白图像,通道优先?
标签: tensorflow neural-network tensorflow2.0 tf.keras conv-neural-network