快捷鍵

torch.randn_like

torch.randn_like(input, *, dtype=None, layout=None, device=None, requires_grad=False, memory_format=torch.preserve_format) Tensor

返回一個與 input 大小相同的 Tensor,並以平均值為 0 和變異數為 1 的常態分佈中的隨機數字填充。 有關複數 dtype 的採樣過程,請參閱 torch.randn()torch.randn_like(input) 等同於 torch.randn(input.size(), dtype=input.dtype, layout=input.layout, device=input.device)

參數

input (Tensor) – input 的大小將決定輸出 tensor 的大小。

關鍵字參數
  • dtype (torch.dtype, optional) – 返回的 Tensor 所需的資料類型。預設值:如果 None,則預設為 input 的 dtype。

  • layout (torch.layout, optional) – 返回的 tensor 所需的版面配置。預設值:如果 None,則預設為 input 的版面配置。

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

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

  • memory_format (torch.memory_format, optional) – 返回的 Tensor 所需的記憶體格式。預設值: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