The :class:`SignLayer` class is for quantizing the layer outputs to -1 or 1 while inferencing. Parameters ---------- name : a str A unique layer name.
| 14 | |
| 15 | |
| 16 | class Sign(Layer): |
| 17 | """The :class:`SignLayer` class is for quantizing the layer outputs to -1 or 1 while inferencing. |
| 18 | |
| 19 | Parameters |
| 20 | ---------- |
| 21 | name : a str |
| 22 | A unique layer name. |
| 23 | |
| 24 | """ |
| 25 | |
| 26 | # @deprecated_alias(layer='prev_layer', end_support_version=1.9) # TODO remove this line for the 1.9 release |
| 27 | def __init__( |
| 28 | self, |
| 29 | name=None # 'sign', |
| 30 | ): |
| 31 | super().__init__(name) |
| 32 | logging.info("Sign %s" % self.name) |
| 33 | |
| 34 | self.build() |
| 35 | self._built = True |
| 36 | |
| 37 | def build(self, inputs_shape=None): |
| 38 | pass |
| 39 | |
| 40 | def __repr__(self): |
| 41 | s = ('{classname}(') |
| 42 | if self.name is not None: |
| 43 | s += ', name=\'{name}\'' |
| 44 | s += ')' |
| 45 | return s.format(classname=self.__class__.__name__, **self.__dict__) |
| 46 | |
| 47 | def forward(self, inputs): |
| 48 | # with tf.variable_scope(name): |
| 49 | ## self.outputs = tl.act.sign(self.inputs) |
| 50 | # self.outputs = quantize(self.inputs) |
| 51 | outputs = quantize(inputs) |
| 52 | return outputs |
no outgoing calls
no test coverage detected
searching dependent graphs…