2. Pytorch 기본 코드!

2023. 11. 13. 15:03NAVER AI Tech/Pytorch

numpy + AutoGrad를 제공.

 

기본 벡터 다루는 내장 함수들

1. tensor.reshape()

2. tensor.squeeze()

3. tensor.unsqueeze()

4. tensor1.matmul(tensor2), tensor1.mm(tensor2) : element-wise 곱 but matmul은 broadcasting을 지원해주므로 조심할 것

5. tensor1.dot(tensor2) : 행렬 내적 곱

 

import torch.nn.functional as F # 이거 진짜 많이쓴다~ 유용한 기능 많음

- F.softmax(tensor, dim=0)

- F.one_hot(tensor)

 

z.backward() : 미분 수행

w.grad() : 기울기 값을 반환.

 

'NAVER AI Tech > Pytorch' 카테고리의 다른 글

6. 모델 저장, 불러오기  (0) 2023.11.17
5. pytorch dataset  (0) 2023.11.16
4. AutoGrad & Optimizer  (0) 2023.11.16
3. Pytorch 프로젝트 구조  (0) 2023.11.13
1. Pytorch란?  (0) 2023.11.13