1. 程式人生 > >Pytorch報錯:RuntimeError: "exp" not implemented for 'torch.IntTensor'或者是'torch.LongTensor'

Pytorch報錯:RuntimeError: "exp" not implemented for 'torch.IntTensor'或者是'torch.LongTensor'

報錯展示:

目的是以下實現函式:

原先輸入變數是:torch.int64報錯是:

然後嘗試將torch.LongTensor轉換為:torch.IntTensor型別:

注意強制轉換的操作是:直接在變數後面新增.int()、.folat()等,進行變數型別的變換。

無奈的是還存在同樣的錯誤。

然後,嘗試將torch.LongTensor轉換為:torch.FolatTensor型別:

測試程式碼,報錯解決。

總結:在Pytorch下的torch的exp運算是針對浮點資料型別的。