可视化keras中的辍学层

时间:2019-10-15 13:05:24

标签: python github keras visualization

我发现了这个github repository,它很好地描绘了深度学习架构。

现在我想以某种方式绘制该仓库中不可用的Dropout层。我尝试创建2个新类:在Conv层之后用于Dropout层的DropoutConv2D和在像这样的致密层之后用于dropout层的DropoutDense。

class DropoutDense(Layer):
    def __init__(self):
        super(DropoutDense, self).__init__(filters = units)
    def get_description(self):
        return ["dropout"]
    def set_objects(self):
        x1 = self.prev_feature_map.right
        y11 = - math.pow(self.prev_feature_map.c, config.channel_scale) / 2
        y12 = math.pow(self.prev_feature_map.c, config.channel_scale) / 2
        x2 = self.next_feature_map.left
        y2 = - math.pow(self.next_feature_map.c, config.channel_scale) / 4
        line_color = config.line_color_layer
        self.objects.append(Line(x1, y11, x2, y2, color=line_color, dasharray=2))
        self.objects.append(Line(x1, y12, x2, y2, color=line_color, dasharray=2))

        x = (self.prev_feature_map.right + self.next_feature_map.left) / 2
        y = max(self.prev_feature_map.get_bottom(), self.next_feature_map.get_bottom()) + config.text_margin \
            + config.text_size

        for i, description in enumerate(self.get_description()):
            self.objects.append(Text(x, y + i * config.text_size, "{}".format(description),
                                     color=config.text_color_layer, size=config.text_size))

这里的人有没有与此仓库一起工作并给我建议。

0 个答案:

没有答案