def __init__(self, base: Convolution2D, limit: int, removed: int = 0): if base.has_attribute(ConvFilterPruned): raise ValueError( f"\'ConvFilterPruned\' attribute has been already registered to {base}." ) super(ConvFilterPruned, self).__init__(base) self.limit = limit # type: int self.removed = removed # type: int
def get(base: Convolution2D): if base.has_attribute(ConvFilterPruned): return base.get_attribute(ConvFilterPruned)[0]
def has(base: Convolution2D): return base.has_attribute(ConvFilterPruned)