def _construct_CNN(self, input_, p_size, params): # Input block k_size = [ params["k_size_input"], params["k_size_b1"], params["k_size_b2"], params["k_size_b3"] ] model = self._construct_CNN_input(input_, p_size, k_size) # Block 3 res min_3 = (self.CNN_sizes[p_size[3]] - 1) if (self.CNN_sizes[p_size[3]] - 1) > -1 else 0 filters_res = [min_3, min_3, self.CNN_sizes[p_size[3]]] model = cmp.Conv1D_res_block(model, filters_res, k_size[3]) # Dropout model = self._add_dropout(model, DNN=False) # Extra blocks, gotta get deep model = cmp.Conv1D_res_block(model, [128, 128, 128], kernel_shape=3) # Dropout model = self._add_dropout(model, DNN=False) model = cmp.Conv1D_res_block(model, [128, 128, self.CNN_sizes[p_size[3]]], kernel_shape=3) # Dropout model = self._add_dropout(model, DNN=False) if params["type_b4"] == 0: # Block 4 ID filters_id = [self.CNN_sizes[p_size[4]], self.CNN_sizes[p_size[3]]] model = cmp.Conv1D_identity_block(model, filters_id, kernel_shape=3) # Dropout model = self._add_dropout(model, DNN=False) # Flatten for dense model = kl.Flatten()(model) else: # Flatten for dense model = kl.Flatten()(model) # Dense ID Block 4 model = cmp.dense_res_block(model, self.DNN_sizes[p_size[4]]) # Dropout model = self._add_dropout(model, DNN=True) return model
def _construct_CNN_input(self, input_model, p_size, kernels): # CNN input block model = cmp.Conv1D_input_layer(input_model, self.CNN_sizes[p_size[0]], kernel_shape=kernels[0]) # CNN Res Block min_1 = (self.CNN_sizes[p_size[1]] - 1) if (self.CNN_sizes[p_size[1]] - 1) > -1 else 0 filters_res = [min_1, min_1, self.CNN_sizes[p_size[1]]] model = cmp.Conv1D_res_block(model, n_filters=filters_res, kernel_shape=kernels[1]) # Dropout model = self._add_dropout(model, DNN=False) # CNN Identity Block filters_id = [self.CNN_sizes[p_size[2]], self.CNN_sizes[p_size[1]]] model = cmp.Conv1D_identity_block(model, filters_id, kernel_shape=kernels[2]) # Dropout model = self._add_dropout(model, DNN=False) return model