Source code for sinabs.layers.quantize

import torch.nn as nn

from sinabs.activation import Quantize

[docs] class QuantizeLayer(nn.Module): """Layer that quantizes the input, i.e. returns floor(input). Parameters: quantize: If False, this layer will pass on the input without modifying it. """ def __init__(self, quantize=True): super().__init__() self.quantize = quantize
[docs] def forward(self, data): if self.quantize: return Quantize.apply(data) else: return data