Пример #1
0
def test_arguments():
    """
    Args passing during initialization.
    """
    b = msd.Bernoulli()
    assert isinstance(b, msd.Distribution)
    b = msd.Bernoulli([0.1, 0.3, 0.5, 0.9], dtype=dtype.int32)
    assert isinstance(b, msd.Distribution)
Пример #2
0
def test_prob():
    """
    Invalid probability.
    """
    with pytest.raises(ValueError):
        msd.Bernoulli([-0.1], dtype=dtype.int32)
    with pytest.raises(ValueError):
        msd.Bernoulli([1.1], dtype=dtype.int32)
Пример #3
0
 def __init__(self):
     super(KL, self).__init__()
     self.b = msd.Bernoulli(0.7, dtype=dtype.int32)
Пример #4
0
 def __init__(self):
     super(CrossEntropy, self).__init__()
     self.b = msd.Bernoulli(0.7, dtype=dtype.int32)
Пример #5
0
 def __init__(self, shape, seed=0):
     super(Sampling, self).__init__()
     self.b = msd.Bernoulli([0.7, 0.5], seed=seed, dtype=dtype.int32)
     self.shape = shape
Пример #6
0
 def __init__(self):
     super(Basics, self).__init__()
     self.b = msd.Bernoulli([0.3, 0.5, 0.7], dtype=dtype.int32)
Пример #7
0
 def __init__(self):
     super(BernoulliProb1, self).__init__()
     self.b = msd.Bernoulli(dtype=dtype.int32)
Пример #8
0
def test_seed():
    with pytest.raises(TypeError):
        msd.Bernoulli([0.1], seed='seed')
Пример #9
0
def test_name():
    with pytest.raises(TypeError):
        msd.Bernoulli([0.1], name=1.0)
Пример #10
0
def test_type():
    with pytest.raises(TypeError):
        msd.Bernoulli([0.1], dtype=dtype.float32)
Пример #11
0
 def __init__(self):
     super(BernoulliConstruct, self).__init__()
     self.b = msd.Bernoulli(0.5, dtype=dtype.int32)
     self.b1 = msd.Bernoulli(dtype=dtype.int32)
Пример #12
0
 def __init__(self):
     super(BernoulliKl, self).__init__()
     self.b1 = msd.Bernoulli(0.7, dtype=dtype.int32)
     self.b2 = msd.Bernoulli(dtype=dtype.int32)
Пример #13
0
 def __init__(self):
     super(BernoulliEntropy, self).__init__()
     self.b = msd.Bernoulli([0.3, 0.5], dtype=dtype.int32)
Пример #14
0
    def __init__(self):
        super().__init__()
        self.normal_dist = msd.Normal(dtype=mstype.float32)
        self.bernoulli_dist = msd.Bernoulli(dtype=mstype.float32)

        self.reduce_sum = P.ReduceSum(keep_dims=True)