def test_init(): """ Test initializations. """ b = msb.Invert(msb.ScalarAffine(scale=1.0)) assert isinstance(b, msb.Bijector) b = msb.Invert(msb.Exp()) assert isinstance(b, msb.Bijector)
def __init__(self, loc, scale, seed=0, dtype=mstype.float32, name="Gumbel"): """ Constructor of Gumbel distribution. """ valid_dtype = mstype.float_type Validator.check_type_name("dtype", dtype, valid_dtype, type(self).__name__) gumbel_cdf = msb.GumbelCDF(loc, scale) super(Gumbel, self).__init__( distribution=msd.Uniform(0.0, 1.0, dtype=dtype), bijector=msb.Invert(gumbel_cdf), seed=seed, name=name) # overwrite default_parameters and parameter_names self._reset_parameters() self._loc = self._add_parameter(loc, 'loc') self._scale = self._add_parameter(scale, 'scale') self._gumbel_bijector = gumbel_cdf # ops needed for the class self.cast = P.Cast() self.const = P.ScalarToArray() self.exp = exp_generic self.expm1 = expm1_generic self.fill = P.Fill() self.lgamma = nn.LGamma() self.log = log_generic self.shape = P.Shape() self.sqrt = P.Sqrt()
def __init__(self): super(Net3, self).__init__() self.origin = msb.ScalarAffine(scale=2.0, shift=1.0) self.invert = msb.Invert(self.origin)
def __init__(self): super(BackwardJacobian, self).__init__() self.inv1 = msb.Invert(msb.Exp()) self.inv2 = msb.Invert(msb.ScalarAffine())
def __init__(self): super(ForwardBackward, self).__init__() self.inv1 = msb.Invert(msb.Exp()) self.inv2 = msb.Invert(msb.ScalarAffine())
def test_name(): b = msb.Invert(msb.ScalarAffine(scale=1.0)) assert b.name == 'InvertScalarAffine'
def test_type(): with pytest.raises(TypeError): msb.Invert(msb.Exp(), name=0.1) with pytest.raises(TypeError): msb.Invert(0.1)
def __init__(self): super(Net, self).__init__() self.b1 = msb.ScalarAffine(2.0, 1.0) self.inv = msb.Invert(self.b1)