예제 #1
0
def test_type():
    with pytest.raises(TypeError):
        msb.GumbelCDF(scale='scale')
    with pytest.raises(TypeError):
        msb.GumbelCDF(loc='loc')
    with pytest.raises(TypeError):
        msb.GumbelCDF(name=0.1)
예제 #2
0
def test_invalid_scale():
    """
    Test invalid scale.
    """
    with pytest.raises(ValueError):
        msb.GumbelCDF(scale=0.0)
    with pytest.raises(ValueError):
        msb.GumbelCDF(scale=-1.0)
예제 #3
0
def test_init():
    """
    Test initializations.
    """
    b = msb.GumbelCDF()
    assert isinstance(b, msb.Bijector)
    b = msb.GumbelCDF(scale=1.0)
    assert isinstance(b, msb.Bijector)
    b = msb.GumbelCDF(loc=0.0)
    assert isinstance(b, msb.Bijector)
    b = msb.GumbelCDF(3.0, 4.0)
    assert isinstance(b, msb.Bijector)
예제 #4
0
파일: gumbel.py 프로젝트: lynex/mindspore
    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()
예제 #5
0
 def __init__(self):
     super(ForwardJacobian, self).__init__()
     self.b1 = msb.GumbelCDF(1.0, 2.0)
     self.b2 = msb.GumbelCDF()
예제 #6
0
 def __init__(self):
     super(ForwardBackward, self).__init__()
     self.b1 = msb.GumbelCDF(1.0, 2.0)
     self.b2 = msb.GumbelCDF()
예제 #7
0
 def __init__(self):
     super(Net, self).__init__()
     self.b1 = msb.GumbelCDF(1.0, 2.0)
     self.b2 = msb.GumbelCDF()
예제 #8
0
 def __init__(self, loc, scale):
     super(Net3, self).__init__()
     self.bijector = msb.GumbelCDF(loc, scale)