forked from mindspore-Ecosystem/mindspore
fix docs error of probability
This commit is contained in:
parent
4bcf62b171
commit
6f9b1b656f
|
@ -278,7 +278,7 @@ class Bijector(Cell):
|
|||
Args:
|
||||
name (str): The name of the function.
|
||||
*args (list): A list of positional arguments that the function needs.
|
||||
**kwargs (dictionary): A dictionary of keyword arguments that the function needs.
|
||||
**kwargs (dict): A dictionary of keyword arguments that the function needs.
|
||||
"""
|
||||
if name == 'forward':
|
||||
return self.forward(*args, **kwargs)
|
||||
|
|
|
@ -29,6 +29,7 @@ class Invert(Bijector):
|
|||
``Ascend`` ``GPU``
|
||||
|
||||
Examples:
|
||||
>>> import numpy as np
|
||||
>>> import mindspore
|
||||
>>> import mindspore.nn as nn
|
||||
>>> import mindspore.nn.probability.bijector as msb
|
||||
|
@ -44,6 +45,8 @@ class Invert(Bijector):
|
|||
>>> forward = Net()
|
||||
>>> x = np.array([2.0, 3.0, 4.0, 5.0]).astype(np.float32)
|
||||
>>> ans = forward(Tensor(x, dtype=mindspore.float32))
|
||||
>>> print(ans.shape)
|
||||
(4,)
|
||||
"""
|
||||
|
||||
def __init__(self,
|
||||
|
|
|
@ -41,15 +41,26 @@ class WithBNNLossCell(Cell):
|
|||
``Ascend`` ``GPU``
|
||||
|
||||
Examples:
|
||||
>>> import numpy as np
|
||||
>>> import mindspore.nn as nn
|
||||
>>> from mindspore.nn.probability import bnn_layers
|
||||
>>> from mindspore import Tensor
|
||||
>>> class Net(nn.Cell):
|
||||
... def __init__(self):
|
||||
... super(Net, self).__init__()
|
||||
... self.dense = bnn_layers.DenseReparam(16, 1)
|
||||
... def construct(self, x):
|
||||
... return self.dense(x)
|
||||
>>> net = Net()
|
||||
>>> loss_fn = nn.SoftmaxCrossEntropyWithLogits(sparse=False)
|
||||
>>> net_with_criterion = WithBNNLossCell(net, loss_fn)
|
||||
>>> net_with_criterion = bnn_layers.WithBNNLossCell(net, loss_fn)
|
||||
>>>
|
||||
>>> batch_size = 2
|
||||
>>> data = Tensor(np.ones([batch_size, 16]).astype(np.float32) * 0.01)
|
||||
>>> label = Tensor(np.ones([batch_size, 1]).astype(np.float32))
|
||||
>>>
|
||||
>>> net_with_criterion(data, label)
|
||||
>>> output = net_with_criterion(data, label)
|
||||
>>> print(output.shape)
|
||||
(2,)
|
||||
"""
|
||||
|
||||
def __init__(self, backbone, loss_fn, dnn_factor=1, bnn_factor=1):
|
||||
|
|
|
@ -191,19 +191,19 @@ class ConvReparam(_ConvVariational):
|
|||
Default: 1.
|
||||
has_bias (bool): Specifies whether the layer uses a bias vector.
|
||||
Default: False.
|
||||
weight_prior_fn: The prior distribution for weight.
|
||||
weight_prior_fn (Cell): The prior distribution for weight.
|
||||
It must return a mindspore distribution instance.
|
||||
Default: NormalPrior. (which creates an instance of standard
|
||||
normal distribution). The current version only supports normal distribution.
|
||||
weight_posterior_fn: The posterior distribution for sampling weight.
|
||||
weight_posterior_fn (function): The posterior distribution for sampling weight.
|
||||
It must be a function handle which returns a mindspore
|
||||
distribution instance. Default: normal_post_fn.
|
||||
The current version only supports normal distribution.
|
||||
bias_prior_fn: The prior distribution for bias vector. It must return
|
||||
bias_prior_fn (Cell): The prior distribution for bias vector. It must return
|
||||
a mindspore distribution. Default: NormalPrior(which creates an
|
||||
instance of standard normal distribution). The current version
|
||||
only supports normal distribution.
|
||||
bias_posterior_fn: The posterior distribution for sampling bias vector.
|
||||
bias_posterior_fn (function): The posterior distribution for sampling bias vector.
|
||||
It must be a function handle which returns a mindspore
|
||||
distribution instance. Default: normal_post_fn.
|
||||
The current version only supports normal distribution.
|
||||
|
@ -218,7 +218,11 @@ class ConvReparam(_ConvVariational):
|
|||
``Ascend`` ``GPU``
|
||||
|
||||
Examples:
|
||||
>>> net = ConvReparam(120, 240, 4, has_bias=False)
|
||||
>>> import numpy as np
|
||||
>>> import mindspore
|
||||
>>> from mindspore import Tensor
|
||||
>>> from mindspore.nn.probability import bnn_layers
|
||||
>>> net = bnn_layers.ConvReparam(120, 240, 4, has_bias=False)
|
||||
>>> input = Tensor(np.ones([1, 120, 1024, 640]), mindspore.float32)
|
||||
>>> output = net(input).shape
|
||||
>>> print(output)
|
||||
|
|
|
@ -136,19 +136,19 @@ class DenseReparam(_DenseVariational):
|
|||
Note that if the type of activation is Cell, it must be instantiated beforehand.
|
||||
Default: None.
|
||||
has_bias (bool): Specifies whether the layer uses a bias vector. Default: False.
|
||||
weight_prior_fn: The prior distribution for weight.
|
||||
weight_prior_fn (Cell): The prior distribution for weight.
|
||||
It must return a mindspore distribution instance.
|
||||
Default: NormalPrior. (which creates an instance of standard
|
||||
normal distribution). The current version only supports normal distribution.
|
||||
weight_posterior_fn: The posterior distribution for sampling weight.
|
||||
weight_posterior_fn (function): The posterior distribution for sampling weight.
|
||||
It must be a function handle which returns a mindspore
|
||||
distribution instance. Default: normal_post_fn.
|
||||
The current version only supports normal distribution.
|
||||
bias_prior_fn: The prior distribution for bias vector. It must return
|
||||
bias_prior_fn (Cell): The prior distribution for bias vector. It must return
|
||||
a mindspore distribution. Default: NormalPrior(which creates an
|
||||
instance of standard normal distribution). The current version
|
||||
only supports normal distribution.
|
||||
bias_posterior_fn: The posterior distribution for sampling bias vector.
|
||||
bias_posterior_fn (function): The posterior distribution for sampling bias vector.
|
||||
It must be a function handle which returns a mindspore
|
||||
distribution instance. Default: normal_post_fn.
|
||||
The current version only supports normal distribution.
|
||||
|
@ -163,7 +163,11 @@ class DenseReparam(_DenseVariational):
|
|||
``Ascend`` ``GPU``
|
||||
|
||||
Examples:
|
||||
>>> net = DenseReparam(3, 4)
|
||||
>>> import numpy as np
|
||||
>>> import mindspore
|
||||
>>> from mindspore import Tensor
|
||||
>>> from mindspore.nn.probability import bnn_layers
|
||||
>>> net = bnn_layers.DenseReparam(3, 4)
|
||||
>>> input = Tensor(np.random.randint(0, 255, [2, 3]), mindspore.float32)
|
||||
>>> output = net(input).shape
|
||||
>>> print(output)
|
||||
|
@ -225,19 +229,19 @@ class DenseLocalReparam(_DenseVariational):
|
|||
Note that if the type of activation is Cell, it must be instantiated beforehand.
|
||||
Default: None.
|
||||
has_bias (bool): Specifies whether the layer uses a bias vector. Default: False.
|
||||
weight_prior_fn: The prior distribution for weight.
|
||||
weight_prior_fn (Cell): The prior distribution for weight.
|
||||
It must return a mindspore distribution instance.
|
||||
Default: NormalPrior. (which creates an instance of standard
|
||||
normal distribution). The current version only supports normal distribution.
|
||||
weight_posterior_fn: The posterior distribution for sampling weight.
|
||||
weight_posterior_fn (function): The posterior distribution for sampling weight.
|
||||
It must be a function handle which returns a mindspore
|
||||
distribution instance. Default: normal_post_fn.
|
||||
The current version only supports normal distribution.
|
||||
bias_prior_fn: The prior distribution for bias vector. It must return
|
||||
bias_prior_fn (Cell): The prior distribution for bias vector. It must return
|
||||
a mindspore distribution. Default: NormalPrior(which creates an
|
||||
instance of standard normal distribution). The current version
|
||||
only supports normal distribution.
|
||||
bias_posterior_fn: The posterior distribution for sampling bias vector.
|
||||
bias_posterior_fn (function): The posterior distribution for sampling bias vector.
|
||||
It must be a function handle which returns a mindspore
|
||||
distribution instance. Default: normal_post_fn.
|
||||
The current version only supports normal distribution.
|
||||
|
@ -252,7 +256,11 @@ class DenseLocalReparam(_DenseVariational):
|
|||
``Ascend`` ``GPU``
|
||||
|
||||
Examples:
|
||||
>>> net = DenseLocalReparam(3, 4)
|
||||
>>> import numpy as np
|
||||
>>> import mindspore
|
||||
>>> from mindspore import Tensor
|
||||
>>> from mindspore.nn.probability import bnn_layers
|
||||
>>> net = bnn_layers.DenseLocalReparam(3, 4)
|
||||
>>> input = Tensor(np.random.randint(0, 255, [2, 3]), mindspore.float32)
|
||||
>>> output = net(input).shape
|
||||
>>> print(output)
|
||||
|
|
|
@ -282,8 +282,8 @@ class Bernoulli(Distribution):
|
|||
|
||||
Args:
|
||||
dist (str): The type of the distributions. Should be "Bernoulli" in this case.
|
||||
probs1_b (Union[Tensor, numbers.Number]): `probs1` of distribution b.
|
||||
probs1_a (Union[Tensor, numbers.Number]): `probs1` of distribution a. Default: self.probs.
|
||||
probs1_b (Tensor, Number): `probs1` of distribution b.
|
||||
probs1_a (Tensor, Number): `probs1` of distribution a. Default: self.probs.
|
||||
|
||||
.. math::
|
||||
KL(a||b) = probs1_a * \log(\frac{probs1_a}{probs1_b}) +
|
||||
|
|
|
@ -362,7 +362,7 @@ class Distribution(Cell):
|
|||
|
||||
Args:
|
||||
*args (list): the list of positional arguments forwarded to subclasses.
|
||||
**kwargs (dictionary): the dictionary of keyword arguments forwarded to subclasses.
|
||||
**kwargs (dict): the dictionary of keyword arguments forwarded to subclasses.
|
||||
|
||||
Note:
|
||||
`dist_spec_args` must be passed in through list or dictionary. The order of `dist_spec_args`
|
||||
|
@ -394,7 +394,7 @@ class Distribution(Cell):
|
|||
Args:
|
||||
value (Tensor): value to be evaluated.
|
||||
*args (list): the list of positional arguments forwarded to subclasses.
|
||||
**kwargs (dictionary): the dictionary of keyword arguments forwarded to subclasses.
|
||||
**kwargs (dict): the dictionary of keyword arguments forwarded to subclasses.
|
||||
|
||||
Note:
|
||||
A distribution can be optionally passed to the function by passing its dist_spec_args through
|
||||
|
@ -418,7 +418,7 @@ class Distribution(Cell):
|
|||
Args:
|
||||
value (Tensor): value to be evaluated.
|
||||
*args (list): the list of positional arguments forwarded to subclasses.
|
||||
**kwargs (dictionary): the dictionary of keyword arguments forwarded to subclasses.
|
||||
**kwargs (dict): the dictionary of keyword arguments forwarded to subclasses.
|
||||
|
||||
Note:
|
||||
A distribution can be optionally passed to the function by passing its dist_spec_args through
|
||||
|
@ -442,7 +442,7 @@ class Distribution(Cell):
|
|||
Args:
|
||||
value (Tensor): value to be evaluated.
|
||||
*args (list): the list of positional arguments forwarded to subclasses.
|
||||
**kwargs (dictionary): the dictionary of keyword arguments forwarded to subclasses.
|
||||
**kwargs (dict): the dictionary of keyword arguments forwarded to subclasses.
|
||||
|
||||
Note:
|
||||
A distribution can be optionally passed to the function by passing its dist_spec_args through
|
||||
|
@ -484,7 +484,7 @@ class Distribution(Cell):
|
|||
Args:
|
||||
value (Tensor): value to be evaluated.
|
||||
*args (list): the list of positional arguments forwarded to subclasses.
|
||||
**kwargs (dictionary): the dictionary of keyword arguments forwarded to subclasses.
|
||||
**kwargs (dict: the dictionary of keyword arguments forwarded to subclasses.
|
||||
|
||||
Note:
|
||||
A distribution can be optionally passed to the function by passing its dist_spec_args through
|
||||
|
@ -508,7 +508,7 @@ class Distribution(Cell):
|
|||
Args:
|
||||
value (Tensor): value to be evaluated.
|
||||
*args (list): the list of positional arguments forwarded to subclasses.
|
||||
**kwargs (dictionary): the dictionary of keyword arguments forwarded to subclasses.
|
||||
**kwargs (dict): the dictionary of keyword arguments forwarded to subclasses.
|
||||
|
||||
Note:
|
||||
A distribution can be optionally passed to the function by passing its dist_spec_args through
|
||||
|
@ -541,7 +541,7 @@ class Distribution(Cell):
|
|||
Args:
|
||||
value (Tensor): value to be evaluated.
|
||||
*args (list): the list of positional arguments forwarded to subclasses.
|
||||
**kwargs (dictionary): the dictionary of keyword arguments forwarded to subclasses.
|
||||
**kwargs (dict): the dictionary of keyword arguments forwarded to subclasses.
|
||||
|
||||
Note:
|
||||
A distribution can be optionally passed to the function by passing its dist_spec_args through
|
||||
|
@ -568,7 +568,7 @@ class Distribution(Cell):
|
|||
Args:
|
||||
dist (str): type of the distribution.
|
||||
*args (list): the list of positional arguments forwarded to subclasses.
|
||||
**kwargs (dictionary): the dictionary of keyword arguments forwarded to subclasses.
|
||||
**kwargs (dict): the dictionary of keyword arguments forwarded to subclasses.
|
||||
|
||||
Note:
|
||||
dist_spec_args of distribution b must be passed to the function through `args` or `kwargs`.
|
||||
|
@ -585,7 +585,7 @@ class Distribution(Cell):
|
|||
|
||||
Args:
|
||||
*args (list): the list of positional arguments forwarded to subclasses.
|
||||
**kwargs (dictionary): the dictionary of keyword arguments forwarded to subclasses.
|
||||
**kwargs (dict): the dictionary of keyword arguments forwarded to subclasses.
|
||||
|
||||
Note:
|
||||
A distribution can be optionally passed to the function by passing its *dist_spec_args* through
|
||||
|
@ -602,7 +602,7 @@ class Distribution(Cell):
|
|||
|
||||
Args:
|
||||
*args (list): the list of positional arguments forwarded to subclasses.
|
||||
**kwargs (dictionary): the dictionary of keyword arguments forwarded to subclasses.
|
||||
**kwargs (dict): the dictionary of keyword arguments forwarded to subclasses.
|
||||
|
||||
Note:
|
||||
A distribution can be optionally passed to the function by passing its *dist_spec_args* through
|
||||
|
@ -616,7 +616,7 @@ class Distribution(Cell):
|
|||
|
||||
Args:
|
||||
*args (list): the list of positional arguments forwarded to subclasses.
|
||||
**kwargs (dictionary): the dictionary of keyword arguments forwarded to subclasses.
|
||||
**kwargs (dict: the dictionary of keyword arguments forwarded to subclasses.
|
||||
|
||||
Note:
|
||||
A distribution can be optionally passed to the function by passing its *dist_spec_args* through
|
||||
|
@ -630,7 +630,7 @@ class Distribution(Cell):
|
|||
|
||||
Args:
|
||||
*args (list): the list of positional arguments forwarded to subclasses.
|
||||
**kwargs (dictionary): the dictionary of keyword arguments forwarded to subclasses.
|
||||
**kwargs (dict): the dictionary of keyword arguments forwarded to subclasses.
|
||||
|
||||
Note:
|
||||
A distribution can be optionally passed to the function by passing its *dist_spec_args* through
|
||||
|
@ -665,7 +665,7 @@ class Distribution(Cell):
|
|||
|
||||
Args:
|
||||
*args (list): the list of positional arguments forwarded to subclasses.
|
||||
**kwargs (dictionary): the dictionary of keyword arguments forwarded to subclasses.
|
||||
**kwargs (dict): the dictionary of keyword arguments forwarded to subclasses.
|
||||
|
||||
Note:
|
||||
A distribution can be optionally passed to the function by passing its *dist_spec_args* through
|
||||
|
@ -680,7 +680,7 @@ class Distribution(Cell):
|
|||
Args:
|
||||
dist (str): type of the distribution.
|
||||
*args (list): the list of positional arguments forwarded to subclasses.
|
||||
**kwargs (dictionary): the dictionary of keyword arguments forwarded to subclasses.
|
||||
**kwargs (dict): the dictionary of keyword arguments forwarded to subclasses.
|
||||
|
||||
Note:
|
||||
dist_spec_args of distribution b must be passed to the function through `args` or `kwargs`.
|
||||
|
@ -707,7 +707,7 @@ class Distribution(Cell):
|
|||
Args:
|
||||
shape (tuple): shape of the sample.
|
||||
*args (list): the list of positional arguments forwarded to subclasses.
|
||||
**kwargs (dictionary): the dictionary of keyword arguments forwarded to subclasses.
|
||||
**kwargs (dict): the dictionary of keyword arguments forwarded to subclasses.
|
||||
|
||||
Note:
|
||||
A distribution can be optionally passed to the function by passing its *dist_spec_args* through
|
||||
|
@ -728,7 +728,7 @@ class Distribution(Cell):
|
|||
Args:
|
||||
name (str): The name of the function.
|
||||
*args (list): A list of positional arguments that the function needs.
|
||||
**kwargs (dictionary): A dictionary of keyword arguments that the function needs.
|
||||
**kwargs (dict): A dictionary of keyword arguments that the function needs.
|
||||
"""
|
||||
|
||||
if name == 'log_prob':
|
||||
|
|
|
@ -30,9 +30,9 @@ class Gamma(Distribution):
|
|||
|
||||
Args:
|
||||
concentration (list, numpy.ndarray, Tensor): The concentration,
|
||||
also know as alpha of the Gamma distribution.
|
||||
also know as alpha of the Gamma distribution. Default: None.
|
||||
rate (list, numpy.ndarray, Tensor): The rate, also know as
|
||||
beta of the Gamma distribution.
|
||||
beta of the Gamma distribution. Default: None.
|
||||
seed (int): The seed used in sampling. The global seed is used if it is None. Default: None.
|
||||
dtype (mindspore.dtype): The type of the event samples. Default: mstype.float32.
|
||||
name (str): The name of the distribution. Default: 'Gamma'.
|
||||
|
|
|
@ -31,7 +31,7 @@ class Geometric(Distribution):
|
|||
trials when the first success is achieved.
|
||||
|
||||
Args:
|
||||
probs (float, list, numpy.ndarray, Tensor): The probability of success.
|
||||
probs (float, list, numpy.ndarray, Tensor): The probability of success. Default: None.
|
||||
seed (int): The seed used in sampling. Global seed is used if it is None. Default: None.
|
||||
dtype (mindspore.dtype): The type of the event samples. Default: mstype.int32.
|
||||
name (str): The name of the distribution. Default: 'Geometric'.
|
||||
|
|
|
@ -29,9 +29,9 @@ class LogNormal(msd.TransformedDistribution):
|
|||
logarithm is normally distributed. It is constructed as the exponential transformation of a Normal distribution.
|
||||
|
||||
Args:
|
||||
loc (int, float, list, numpy.ndarray, Tensor): The mean of the underlying Normal distribution.
|
||||
loc (int, float, list, numpy.ndarray, Tensor): The mean of the underlying Normal distribution. Default: None.
|
||||
scale (int, float, list, numpy.ndarray, Tensor): The standard deviation of the underlying
|
||||
Normal distribution.
|
||||
Normal distribution. Default: None.
|
||||
seed (int): the seed used in sampling. The global seed is used if it is None. Default: None.
|
||||
dtype (mindspore.dtype): type of the distribution. Default: mstype.float32.
|
||||
name (str): the name of the distribution. Default: 'LogNormal'.
|
||||
|
@ -45,6 +45,7 @@ class LogNormal(msd.TransformedDistribution):
|
|||
`dtype` must be a float type because LogNormal distributions are continuous.
|
||||
|
||||
Examples:
|
||||
>>> import numpy as np
|
||||
>>> import mindspore
|
||||
>>> import mindspore.nn as nn
|
||||
>>> import mindspore.nn.probability.distribution as msd
|
||||
|
@ -57,6 +58,8 @@ class LogNormal(msd.TransformedDistribution):
|
|||
... return self.ln.prob(x_)
|
||||
>>> pdf = Prob()
|
||||
>>> output = pdf(Tensor([1.0, 2.0], dtype=mindspore.float32))
|
||||
>>> print(output.shape)
|
||||
(2, 2)
|
||||
"""
|
||||
|
||||
def __init__(self,
|
||||
|
|
|
@ -28,8 +28,8 @@ class Logistic(Distribution):
|
|||
Logistic distribution.
|
||||
|
||||
Args:
|
||||
loc (int, float, list, numpy.ndarray, Tensor): The location of the Logistic distribution.
|
||||
scale (int, float, list, numpy.ndarray, Tensor): The scale of the Logistic distribution.
|
||||
loc (int, float, list, numpy.ndarray, Tensor): The location of the Logistic distribution. Default: None.
|
||||
scale (int, float, list, numpy.ndarray, Tensor): The scale of the Logistic distribution. Default: None.
|
||||
seed (int): The seed used in sampling. The global seed is used if it is None. Default: None.
|
||||
dtype (mindspore.dtype): The type of the event samples. Default: mstype.float32.
|
||||
name (str): The name of the distribution. Default: 'Logistic'.
|
||||
|
|
|
@ -28,8 +28,8 @@ class Normal(Distribution):
|
|||
Normal distribution.
|
||||
|
||||
Args:
|
||||
mean (int, float, list, numpy.ndarray, Tensor): The mean of the Normal distribution.
|
||||
sd (int, float, list, numpy.ndarray, Tensor): The standard deviation of the Normal distribution.
|
||||
mean (int, float, list, numpy.ndarray, Tensor): The mean of the Normal distribution. Default: None.
|
||||
sd (int, float, list, numpy.ndarray, Tensor): The standard deviation of the Normal distribution. Default: None.
|
||||
seed (int): The seed used in sampling. The global seed is used if it is None. Default: None.
|
||||
dtype (mindspore.dtype): The type of the event samples. Default: mstype.float32.
|
||||
name (str): The name of the distribution. Default: 'Normal'.
|
||||
|
|
|
@ -29,7 +29,7 @@ class Poisson(Distribution):
|
|||
Poisson Distribution.
|
||||
|
||||
Args:
|
||||
rate (list, numpy.ndarray, Tensor): The rate of the Poisson distribution..
|
||||
rate (list, numpy.ndarray, Tensor): The rate of the Poisson distribution. Default: None.
|
||||
seed (int): The seed used in sampling. The global seed is used if it is None. Default: None.
|
||||
dtype (mindspore.dtype): The type of the event samples. Default: mstype.float32.
|
||||
name (str): The name of the distribution. Default: 'Poisson'.
|
||||
|
|
|
@ -52,6 +52,7 @@ class TransformedDistribution(Distribution):
|
|||
`reset_parameters` followed by `add_parameter`.
|
||||
|
||||
Examples:
|
||||
>>> import numpy as np
|
||||
>>> import mindspore
|
||||
>>> import mindspore.nn as nn
|
||||
>>> import mindspore.nn.probability.distribution as msd
|
||||
|
@ -75,6 +76,8 @@ class TransformedDistribution(Distribution):
|
|||
>>> x = np.array([2.0, 3.0, 4.0, 5.0]).astype(np.float32)
|
||||
>>> tx = Tensor(x, dtype=mindspore.float32)
|
||||
>>> cdf, sample = net(tx)
|
||||
>>> print(sample.shape)
|
||||
(2, 3)
|
||||
"""
|
||||
|
||||
def __init__(self,
|
||||
|
|
|
@ -28,8 +28,8 @@ class Uniform(Distribution):
|
|||
Example class: Uniform Distribution.
|
||||
|
||||
Args:
|
||||
low (int, float, list, numpy.ndarray, Tensor): The lower bound of the distribution.
|
||||
high (int, float, list, numpy.ndarray, Tensor): The upper bound of the distribution.
|
||||
low (int, float, list, numpy.ndarray, Tensor): The lower bound of the distribution. Default: None.
|
||||
high (int, float, list, numpy.ndarray, Tensor): The upper bound of the distribution. Default: None.
|
||||
seed (int): The seed uses in sampling. The global seed is used if it is None. Default: None.
|
||||
dtype (mindspore.dtype): The type of the event samples. Default: mstype.float32.
|
||||
name (str): The name of the distribution. Default: 'Uniform'.
|
||||
|
|
|
@ -33,8 +33,8 @@ class VAEAnomalyDetection:
|
|||
Args:
|
||||
encoder(Cell): The Deep Neural Network (DNN) model defined as encoder.
|
||||
decoder(Cell): The DNN model defined as decoder.
|
||||
hidden_size(int): The size of encoder's output tensor.
|
||||
latent_size(int): The size of the latent space.
|
||||
hidden_size(int): The size of encoder's output tensor. Default: 400.
|
||||
latent_size(int): The size of the latent space. Default: 20.
|
||||
|
||||
Supported Platforms:
|
||||
``Ascend`` ``GPU``
|
||||
|
|
|
@ -58,10 +58,8 @@ class UncertaintyEvaluation:
|
|||
|
||||
Examples:
|
||||
>>> network = LeNet()
|
||||
>>> param_dict = load_checkpoint('checkpoint_lenet.ckpt')
|
||||
>>> load_param_into_net(network, param_dict)
|
||||
>>> ds_train = create_dataset('workspace/mnist/train')
|
||||
>>> ds_eval = create_dataset('workspace/mnist/test')
|
||||
>>> ds_train = create_dataset('workspace/mnist/train') # handle train data
|
||||
>>> ds_eval = create_dataset('workspace/mnist/test') # handle test data
|
||||
>>> evaluation = UncertaintyEvaluation(model=network,
|
||||
... train_dataset=ds_train,
|
||||
... task_type='classification',
|
||||
|
|
|
@ -161,7 +161,9 @@ class TransformToBNN:
|
|||
``Ascend`` ``GPU``
|
||||
|
||||
Examples:
|
||||
>>> net = Net()
|
||||
>>> import mindspore.nn as nn
|
||||
>>> from mindspore.nn.probability import bnn_layers
|
||||
>>> net = LeNet()
|
||||
>>> criterion = nn.SoftmaxCrossEntropyWithLogits(sparse=True)
|
||||
>>> optim = nn.AdamWeightDecay(params=net.trainable_params(), learning_rate=0.0001)
|
||||
>>> net_with_loss = nn.WithLossCell(net, criterion)
|
||||
|
|
Loading…
Reference in New Issue