Ejemplo n.º 1
0
    def convert_to_qkeras_quantizer(self,
                                    alpha=None,
                                    temperature=6.0,
                                    use_real_sigmoid=True):
        """convert qtools quantizer to qkeras quantizer."""

        return quantizers.bernoulli(alpha=alpha,
                                    temperature=temperature,
                                    use_real_sigmoid=use_real_sigmoid)
Ejemplo n.º 2
0
def test_Bernoulli():
  qkeras_quantizer = quantizers.bernoulli()
  qtools_quantizer = quantizer_impl.Bernoulli()
  qtools_quantizer.convert_qkeras_quantizer(qkeras_quantizer)
  new_quantizer = qtools_quantizer.convert_to_qkeras_quantizer(
      alpha=qkeras_quantizer.alpha, temperature=qkeras_quantizer.temperature,
      use_real_sigmoid=qkeras_quantizer.use_real_sigmoid)

  result = new_quantizer.__dict__
  for (key, val) in result.items():
    assert_equal(val, qkeras_quantizer.__dict__[key])