快捷方式

torch.result_type

torch.result_type(tensor1, tensor2) dtype

傳回對提供的輸入張量執行算術運算後產生的 torch.dtype 。 關於型別提升邏輯的更多資訊,請參閱型別提升文件

參數
  • tensor1 (TensorNumber) – 一個輸入張量或數字

  • tensor2 (TensorNumber) – 一個輸入張量或數字

範例

>>> torch.result_type(torch.tensor([1, 2], dtype=torch.int), 1.0)
torch.float32
>>> torch.result_type(torch.tensor([1, 2], dtype=torch.uint8), torch.tensor(1))
torch.uint8

文件

獲取 PyTorch 的完整開發者文件

查看文件

教學課程

獲取面向初學者和進階開發者的深入教學課程

查看教學課程

資源

尋找開發資源並獲得問題解答

查看資源