def one_block_model(self, input_tensor):
"""
Model for the twoPathways CNN.
It doesn't compile the model.
The consist of two streams, namely:
local_path anc global_path joined
in a final stream named path
local_path is articulated through:
1st convolution 64x7x7 + relu
1st maxpooling 4x4
1st Dropout with rate: 0.5
2nd convolution 64x3x3 + relu
2nd maxpooling 2x2
2nd droput with rate: 0.5
global_path is articulated through:
convolution 160x13x13 + relu
dropout with rate: 0.5
path is articulated through:
convolution 5x21x21
:param input_tensor: tensor, to feed the two path
:return: output: tensor, the output of the cnn
"""
# localPath
loc_path = Conv2D(64, (7, 7), padding='valid', activation='relu', use_bias=True,
kernel_regularizer=regularizers.l1_l2(self.l1_rate, self.l2_rate),
kernel_constraint=max_norm(2.),
bias_constraint=max_norm(2.))(input_tensor)
loc_path = MaxPooling2D(pool_size=(4, 4), strides=1, padding='valid')(loc_path)
loc_path = Dropout(self.dropout_rate)(loc_path)
loc_path = Conv2D(64, (3, 3), padding='valid', activation='relu', use_bias=True,
kernel_regularizer=regularizers.l1_l2(self.l1_rate, self.l2_rate),
kernel_constraint=max_norm(2.),
bias_constraint=max_norm(2.))(loc_path)
loc_path = MaxPooling2D(pool_size=(2, 2), strides=1, padding='valid')(loc_path)
loc_path = Dropout(self.dropout_rate)(loc_path)
# globalPath
glob_path = Conv2D(160, (13, 13), strides=1, padding='valid', activation='relu', use_bias=True,
kernel_regularizer=regularizers.l1_l2(self.l1_rate, self.l2_rate),
kernel_constraint=max_norm(2.),
bias_constraint=max_norm(2.))(input_tensor)
glob_path = Dropout(self.dropout_rate)(glob_path)
# concatenation of the two path
path = Concatenate(axis=-1)([loc_path, glob_path])
# output layer
output = Conv2D(5, (21, 21), strides=1, padding='valid', activation='softmax', use_bias=True)(path)
return output
评论列表
文章目录