tflearn / tensorflow |多流/多尺度/集合模型定义

时间:2016-07-23 21:15:41

标签: python machine-learning computer-vision tensorflow deep-learning

我正在尝试使用tflearn定义一个多流模型,以便有两个相同架构的副本(或者您可以将其视为一个整体模型),我用同一图像的不同作物提供但不确定我将如何用tflearn实现它。

我基本上有这些数据:

X_train1, X_test1, y_train1, y_test1 : Dataset 1 (16images x 299 x 299px x 3ch)
X_train2, X_test2, y_train2, y_test2 : Dataset 2 (16images x 299 x 299px x 3ch)

到目前为止,我已基于logical.py example(简化代码)创建了此内容:

netIn1 = tflearn.input_data(shape=[None, 299, 299, 3]    
net1 = tflearn.conv_2d(netIn1, 16, 3, regularizer='L2', weight_decay=0.0001)
...
net1 = tflearn.fully_connected(net1, nbClasses, activation='sigmoid')
net1 = tflearn.regression(net1, optimizer=adam, loss='binary_crossentropy')

netIn2 = tflearn.input_data(shape=[None, 299, 299, 3]    
net2 = tflearn.conv_2d(netIn2, 16, 3, regularizer='L2', weight_decay=0.0001)
...
net2 = tflearn.fully_connected(net2, nbClasses, activation='sigmoid')
net2 = tflearn.regression(net2, optimizer=adam, loss='binary_crossentropy')

然后通过连接来合并两个网络:

net = tflearn.merge([net1, net2], mode = 'concat', axis = 1)

开始训练:

# Training
model = tflearn.DNN(net, checkpoint_path='model',
                max_checkpoints=10, tensorboard_verbose=3,
                clip_gradients=0.)

model.fit([X1,X2], [Y1,Y2], validation_set=([testX1, testX2], [testY1,testY2]))

所以现在我的问题是如何在网络开始时解析输入?如何将X1拆分为net1,将X2拆分为net2?

1 个答案:

答案 0 :(得分:0)

您不需要拆分X1和X2,它们将自动分配到您的输入图层netIn1和netIn2(按照您定义它们的顺序)。