捷徑

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, optional) – 從分佈中抽取的最小整數。預設值:0。

  • high (int) – 從分佈中抽取的最大整數之上的一個整數。

關鍵字參數
  • dtype (torch.dtype, optional) – 返回的張量所需的数据类型。 預設值:如果 None,則預設為 input 的 dtype。

  • layout (torch.layout, optional) – 返回的張量所需的佈局。 預設值:如果 None,則預設為 input 的佈局。

  • device (torch.device, optional) – 返回的張量所需的設備。 預設值:如果 None,則預設為 input 的設備。

  • requires_grad (bool, optional) – 如果 autograd 應該記錄返回的張量上的操作。 預設值:False

  • memory_format (torch.memory_format, optional) – 返回的張量所需的記憶體格式。 預設值:torch.preserve_format

文件

Access comprehensive developer documentation for PyTorch

View Docs

Tutorials

Get in-depth tutorials for beginners and advanced developers

View Tutorials

Resources

Find development resources and get your questions answered

View Resources