본문 바로가기

Language&Framework&Etc/Pytorch7

Pytorch란 무엇인가요? - 연산 (Pytorch 학습 2) 1. 덧셈 import torch # 1 x = torch.ones(5, 3) y = torch.rand(5, 3) print(x + y) # 2 print(torch.add(x, y)) # 3 result = torch.empty(5, 3) torch.add(x, y, out=result) print(result) # 4 in-place y.add_(x) print(y) 위 출력 결과는 모두 동일하다. tensor([[1.5353, 1.6422, 1.8407], [1.9036, 1.7170, 1.7341], [1.9691, 1.9267, 1.1749], [1.5314, 1.8827, 1.8450], [1.7856, 1.8662, 1.8147]]) tensor([[1.5353, 1.6422, 1.8407.. 2021. 4. 16.
Pytorch란 무엇인가요? - 시작하기 (Pytorch 학습 1) 1. 초기화되지 않은 행렬 선언 import torch x = torch.empty(5, 3) print(x) - 초기화되지 않은 행렬이 선언되었지만, 사용하기 전에는 명확히 알려진 값을 포함하고 있지는 않는다. - 위의 empty와 같이 초기화되지 않은 행렬이 생성되면 그 시점에 할당된 메모리에 존재하던 값들이 초기값. 출력 (shape : 5 x 3) tensor([[8.4490e-39, 9.6429e-39, 9.2755e-39], [1.0286e-38, 9.0919e-39, 8.9082e-39], [9.2755e-39, 8.4490e-39, 1.0194e-38], [9.0919e-39, 8.4490e-39, 9.6429e-39], [1.0653e-38, 9.6429e-39, 1.0745e-38]]).. 2021. 4. 16.
TorchVision model funetuning Pytorch에서 fine-tuning하는 방법을 확인해보려고 합니다. 모델은 torchvision models 중 선택할 수 있으며, 모두 1000-class Imagenet datasets로 pre-trained되었습니다. 참고 링크에 fine-tuning과 feature-extraction 이렇게 두 가지 타입의 transfer learning을 수행합니다. 1) Fintuning : pre-trained된 모델로 시작하여 새로운 task에 대한 model의 모든 parameter를 업데이트합니다. 본질적으로 전체 model을 retraining 합니다. 2) Feature extraction : pre-trained된 모델로 시작하여 prediction을 도출하는 마지막 레이어의 weight만 업.. 2021. 1. 30.