评价此页

torch.randint_like#

torch.randint_like(input, low=0, high, \*, dtype=None, layout=torch.strided, device=None, requires_grad=False, memory_format=torch.preserve_format) Tensor#

返回一个与张量 input 形状相同的张量,其中填充了在 low(包含)和 high(不包含)之间均匀生成的随机整数。

参数
  • input (Tensor) – input 的大小将决定输出张量的大小。

  • low (int, 可选) – 从分布中抽取的最低整数。默认值:0。

  • high (int) – 高于从分布中抽取的最高整数的值。

关键字参数
  • dtype (torch.dtype, 可选) – 返回张量所需的数据类型。默认值:如果为 None,则默认为 input 的 dtype。

  • layout (torch.layout, 可选) – 返回张量所需的布局。默认值:如果为 None,则默认为 input 的布局。

  • device (torch.device, 可选) – 返回张量所需的设备。默认值:如果为 None,则默认为 input 的设备。

  • requires_grad (bool, 可选) – 如果自动求导应该记录返回张量上的操作。默认值:False

  • memory_format (torch.memory_format, 可选) – 返回张量所需的内存格式。默认值:torch.preserve_format