maxframe.tensor.random.standard_normal#

maxframe.tensor.random.standard_normal(size=None, chunk_size=None, gpu=None, dtype=None)[源代码]#

从标准正态分布(均值=0,标准差=1)中抽取样本。

参数:
  • size (int or tuple of ints, optional) -- 输出形状。如果给定的形状是,例如 (m, n, k),那么将抽取 m * n * k 个样本。默认为 None,此时返回单个值。

  • chunk_size (int or tuple of int or tuple of ints, optional) -- 每个维度上期望的块大小

  • gpu (bool, optional) -- 如果为 True,则在 GPU 上分配张量,默认为 False

  • dtype (data-type, optional) -- 返回张量的数据类型。

返回:

out -- 抽取的样本。

返回类型:

float or Tensor

示例

>>> import maxframe.tensor as mt
>>> s = mt.random.standard_normal(8000)
>>> s.execute()
array([ 0.6888893 ,  0.78096262, -0.89086505, ...,  0.49876311, #random
       -0.38672696, -0.4685006 ])                               #random
>>> s.shape
(8000,)
>>> s = mt.random.standard_normal(size=(3, 4, 2))
>>> s.shape
(3, 4, 2)