pytorch torch.item()(返回此张量的值作为标准Python数字。 这仅适用于具有一个元素的张量。)
生活随笔
收集整理的這篇文章主要介紹了
pytorch torch.item()(返回此张量的值作为标准Python数字。 这仅适用于具有一个元素的张量。)
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
https://pytorch.org/docs/1.1.0/tensors.html?highlight=item#torch.Tensor.item
item() → number
Returns the value of this tensor as a standard Python number. This only works for tensors with one element. For other cases, see tolist().
返回此張量的值作為標準Python數。 這僅適用于具有一個元素的張量。 對于其他情況,請參見tolist()。
This operation is not differentiable.
此操作不可區分。
Example:
x = torch.tensor([1.0])
x.item()
1.0
總結
以上是生活随笔為你收集整理的pytorch torch.item()(返回此张量的值作为标准Python数字。 这仅适用于具有一个元素的张量。)的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: pytorch torch.Tensor
- 下一篇: numpy.ndarray.reshap