mlp.py 文件源码

python
阅读 35 收藏 0 点赞 0 评论 0

项目:pydl 作者: rafaeltg 项目源码 文件源码
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))
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号