torch.float()
_, argmax = torch.max(outputs, 1)
accuracy = (labels == argmax).float().mean()
torch.tensor.float()는 인자값을 넣지 않고 실행시킨다.
TORCH.TENSOR.FLOAT
Tensor.float(memory_format=torch.preserve_format) → Tensor
self.float() is equivalent to self.to(torch.float32). See to().
Parameters
memory_format (torch.memory_format, optional) – the desired memory format of returned Tensor. Default: torch.preserve_format.
torch.mean()
- torch.mean (Python function, in torch.mean)
- torch.Tensor.mean (Python method, in torch.Tensor.mean)
torch.Tensor.mean — PyTorch 1.9.0 documentation
Shortcuts
pytorch.org


tensor를 float()로 만든다.
- torch.mean(input)
- input.mean()
두 가지 방법이 있다.

- torch.tensor는 객체 자체를 계산시키는 방법이다.
- torch.mean은 함수로 인자값을 넣어 계산한다.
https://frieden1946.tistory.com/556?category=952749 에서 나온 차이점과 동일하다고 할 수 있다.
'AI > PyTorch' 카테고리의 다른 글
[PyTorch] torch.save(model.state_dict(), PATH) / torch.load(PATH) (0) | 2021.06.29 |
---|---|
[PyTorch] torch.tensor와 torch (0) | 2021.06.29 |
[PyTorch] torch.max(outputs, 1) (0) | 2021.06.29 |
[PyTorch] Conv1d, Conv2d 차이점 (0) | 2021.06.29 |
[PyTorch] CNN 설계 7 - 9 (0) | 2021.06.15 |