일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | 5 | 6 | 7 |
8 | 9 | 10 | 11 | 12 | 13 | 14 |
15 | 16 | 17 | 18 | 19 | 20 | 21 |
22 | 23 | 24 | 25 | 26 | 27 | 28 |
29 | 30 |
- 그래프이론
- Coursera
- Study
- DP
- LLM
- 코딩테스트
- 최단경로
- Scaling Laws
- Python
- 파이썬
- 파인튜닝
- paper review
- Generative AI
- 완전탐색
- 코드트리
- 플로이드와샬
- 머신러닝
- 이분탐색
- 판다스
- speaking
- Lora
- peft
- 코딩테스트실력진단
- 스터디
- Fine-Tuning
- 프로그래머스
- 데이터분석
- bfs/dfs
- English
- 알고리즘
- Today
- Total
목록Machine & Deep Learning/Pytorch (2)
생각하는 아져씨
역전파란? 인공 신경망을 최적화 하는 과정에서 미분은 필수적인 요소인데 파이토치는 최적화 과정인 역전파(backpropagation)를 쉽게 할 수 있도록 자동 미분 계산을 제공한다. 자동 미분 준비하기 자동 미분을 하기 위해서는 텐서를 기준으로 모든 연산들을 추적할 수 있어야 한다. 그것이 바로 requires_grad = True 옵션이다. requires_grad = True 해당 텐서를 기준으로 모든 연산들을 추적할 수 있게 하는 옵션이다. (x 기준으로 미분을 할 수 있도록 만들어주는 장치) x = torch.ones(2,2, requires_grad=True) print(x) >> tensor([[1., 1.], [1., 1.]], requires_grad=True) 예를 들어 다음의 계산이 ..
텐서란 텐서(Tensor)는 파이토치의 기본 단위이며 GPU 연산을 가능하게 한다. 또한 Numpy의 배열과 유사하여 손쉽게 다룰 수 있다. 배열(Array)이나 행렬(Matrix)과 유사한 특수한 자료 구조이다. 텐서를 사용하기 위해서는 다음의 라이브러리가 필요하다. # 라이브러리 불러오기 import torch # Pytorch를 사용하기 위한 기본 라이브러리다. numpy와 유사한 함수를 제공해준다. import numpy as np # Numpy를 사용하기 위한 기본 라이브러리다. 여기서 "as np"는 numpy를 np로 짧게 표기하겠다는 뜻이다. 텐서 만들기 빈 텐서 만들기 # 빈 텐서 생성 x = torch.empty(5,4) # 5x4 행렬 생성 print(x) # 초기화되지 않은 행렬인 ..