Tensor.item() → number
将此张量的值作为标准 Python 数字返回。 这仅适用于具有一个元素的张量。 对于其他情况,请参见 tolist()。
这个操作是不可微的。
例子:
>>> x = torch.tensor([1.0])
>>> x.item()
1.0
Tensor.item() → number
将此张量的值作为标准 Python 数字返回。 这仅适用于具有一个元素的张量。 对于其他情况,请参见 tolist()。
这个操作是不可微的。
例子:
>>> x = torch.tensor([1.0])
>>> x.item()
1.0