def _create_layers(self, input_shape, n_output):
""" Create the network layers
:param input_shape:
:param n_output:
:return: self
"""
# Hidden layers
for i, l in enumerate(self.layers):
self._model.add(Dense(units=l,
input_shape=[input_shape[-1] if i == 0 else None],
activation=self.activation[i],
kernel_regularizer=l1_l2(self.l1_reg[i], self.l2_reg[i]),
bias_regularizer=l1_l2(self.l1_reg[i], self.l2_reg[i])))
if self.dropout[i] > 0:
self._model.add(Dropout(rate=self.dropout[i]))
# Output layer
self._model.add(Dense(units=n_output, activation=self.out_activation))
评论列表
文章目录