분류 전체보기
-
[pytorch] numpy를 tensor로 변환하기Study Bits 2023. 9. 21. 22:12
torch.Tensor() 입력된 numpy array가 복제되어 tensor가 만들어진다. torch.from_numpy(), as_tensor() 입력된 numpy array를 tensor로 바꿔 반환된다. 데이터가 복제되지 않고 메모리 버퍼가 공유되기 때문에, array 변경시 tensor 데이터도 변경된다. import torch import numpy as np a = np.zeros([1, 2, 3, 4]) tensor_a = torch.from_numpy(a) tensor_a = torch.as_tensor(a)
-
[논문리뷰] Digging Into Self-Supervised Monocular Depth Estimation, ICCV 2019Papers 2023. 9. 3. 20:32
[ 작성중 ] ICCV 2019 UCL, Caltech, Niantic Yoonwoo Jeong, Seungjoo Shin, Junha Lee, Chris Choy, Anima Anandkumar, Minsu Cho, Jaesik Park pdf code Summary Self-supervised 방식으로 단안 렌즈 카메라의 Depth를 추정. 단일 프레임에서 depth를 예측하기 위해 depth 및 pose를 예측하는 두 가지 네트워크의 조합을 사용. 다양한 손실 함수와 연속적인 프레임을 사용하여 이 두 가지의 네트워크를 훈련시킨다. Pose 추정 네트워크는 학습을 제한하기 위해 사용한다. (Constrained Learning) 정답(Ground Truth, GT) 데이터셋 없이 연속적인 프레임 (t..
-
-
[Vim] 유용한 단축키 모음 (Vim tricks you should know)Study Bits 2023. 8. 21. 19:39
이동 (Move) % : parenthesis, bracket, curly brace 로 점프한다. (Python에서는 무의미한것 같기도...) ctrl+d : 반 페이지 아래로 이동 ctrl+u : 반 페이지 위로 이동 반복 (Repeat) . : (Normal Mode) 마지막에 수행한 작업을 반복한다. 일련의 작업을 반복하고자 할 때, qa : (Normal Mode) Recording Start q : (Normal Mode) Recording End @a : (Normal Mode) Recording 된 작업 반복 검색 (Search) :set hlsearch : 검색하고자 하는 패턴을 하이라이트 하고자 할 때 (On). :nohlsearch : 검색 패턴 하이라이트를 끌 때 (Off).
-
[Python/Pytorch] 데이터 타입(DataType) 조회하는 방법Debug 2023. 8. 21. 02:56
데이터 타입에 따라 dtype 조회하는 방법이 다르다. List, Int 등 기본 데이터 타입 # 1 a = dict() type(a) # 2 isinstance(a, dict) tensor (torch) 데이터 타입 a = torch.zeros(1, 3) torch.is_tensor(a) tensor.float32 등의 데이터 타입 a = torch.zeros(1, 3) torch.dtype tensor의 데이터 타입 변환시 아래와 같이 코드를 작성하면 된다. 단, torch.float32는 float 타입이지만, torch.float64는 double 타입으로 인식하는 것에 유의하자. a = torch.zeros(1, 3, dtype=torch.int32) b = torch.Tensor([1.3, 2..
-
[Pytorch] tensor로 구성된 list를 tensor로 만드는 방법Debug 2023. 8. 21. 02:47
▶ 현상 List Object를 tensor 타입으로 만들고 싶을 때, 리스트 구성 요소가 tensor일 때 torch.Tensor class를 생성하며 인자로 list를 넘겨주면 에러가 발생한다. import torch a = list(torch.zeros(1, 3)) tensor_a = torch.Tensor(a) # ValueError: only one element tensors can be converted to Python scalars ▶ 발생 에러 ValueError: only one element tensors can be converted to Python scalars ▶ 해결 방법 tensor_a = torch.stack(a, dim=0) # tensor([[0., 0., 0.]])
-
[Pytorch/Pytorch Lightning] RuntimeError: element 0 of tensors does not require grad and does not have a grad_fnDebug 2023. 8. 20. 23:12
환경: CentOS Linux release 7.9.2009 ▶ 에러 메세지 File "~/anaconda3/envs/venv/lib/python3.8/site-packages/pytorch_lightning/core/module.py", line 1419, in backward loss.backward(*args, **kwargs) File "~/anaconda3/envs/venv/lib/python3.8/site-packages/torch/_tensor.py", line 363, in backward torch.autograd.backward(self, gradient, retain_graph, create_graph, inputs=inputs) ▶ 문제 원인 loss가 requires_grad = ..