def two_blocks_dcnn(self):
"""
Method to model and compile the first CNN and the whole two blocks DCNN.
Also initialize the field cnn1
:return: Model, Two blocks DeepCNN compiled
"""
# input layers
input65 = Input(shape=(65, 65, 4))
input33 = Input(shape=(33, 33, 4))
# first CNN modeling
output_cnn1 = self.one_block_model(input65)
# first cnn compiling
cnn1 = Model(inputs=input65, outputs=output_cnn1)
sgd = SGD(lr=self.learning_rate, momentum=self.momentum_rate, decay=self.decay_rate, nesterov=False)
cnn1.compile(loss='categorical_crossentropy', optimizer=sgd, metrics=['accuracy'])
# initialize the field cnn1
self.cnn1 = cnn1
print 'first CNN compiled!'
# concatenation of the output of the first CNN and the input of shape 33x33
conc_input = Concatenate(axis=-1)([input33, output_cnn1])
# second cnn modeling
output_dcnn = self.one_block_model(conc_input)
# whole dcnn compiling
dcnn = Model(inputs=[input65, input33], outputs=output_dcnn)
sgd = SGD(lr=self.learning_rate, momentum=self.momentum_rate, decay=self.decay_rate, nesterov=False)
dcnn.compile(loss='categorical_crossentropy', optimizer=sgd, metrics=['accuracy'])
print 'DCNN compiled!'
return dcnn
评论列表
文章目录