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)
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)
def __init__(self): super(KL, self).__init__() self.b = msd.Bernoulli(0.7, dtype=dtype.int32)
def __init__(self): super(CrossEntropy, self).__init__() self.b = msd.Bernoulli(0.7, dtype=dtype.int32)
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
def __init__(self): super(Basics, self).__init__() self.b = msd.Bernoulli([0.3, 0.5, 0.7], dtype=dtype.int32)
def __init__(self): super(BernoulliProb1, self).__init__() self.b = msd.Bernoulli(dtype=dtype.int32)
def test_seed(): with pytest.raises(TypeError): msd.Bernoulli([0.1], seed='seed')
def test_name(): with pytest.raises(TypeError): msd.Bernoulli([0.1], name=1.0)
def test_type(): with pytest.raises(TypeError): msd.Bernoulli([0.1], dtype=dtype.float32)
def __init__(self): super(BernoulliConstruct, self).__init__() self.b = msd.Bernoulli(0.5, dtype=dtype.int32) self.b1 = msd.Bernoulli(dtype=dtype.int32)
def __init__(self): super(BernoulliKl, self).__init__() self.b1 = msd.Bernoulli(0.7, dtype=dtype.int32) self.b2 = msd.Bernoulli(dtype=dtype.int32)
def __init__(self): super(BernoulliEntropy, self).__init__() self.b = msd.Bernoulli([0.3, 0.5], dtype=dtype.int32)
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)