본문 바로가기

분류 전체보기118

[Pytorch] 분류(classification)문제 에서 label 변환 (one-hot vs class) bce를 사용하는등의 거나 여러 상황에서 class의 label을one-hot label로 혹은 class label 로 변환해야 하는 때가 있다. 1. one-hot label 에서 class label 로 변환 : torch.argmax(dim) shape 변환 (*, num_classes) 에서 (*) 로 바뀐다. import torch one_hot_label = torch.tensor([[1, 0, 0, 0], [0, 0, 1, 0]]) class_label = torch.argmax(one_hot_label, dim=-1) print(class_label) 정답 : tensor([0, 2]) 2. class label 에서 one-hot label로 변환 : torch.nn.functional.. 2022. 12. 4.
pytorch TypeError: 'int' object is not callable python 에서 TypeError: 'int' object is not callable 문제 import numpy as np score = np.array([1, 2, 3, 4, 5]) n_object = score.size(0) TypeError: 'int' object is not callable 는 예약어(max, list, sum, module...등) 를 변수명으로 사용할 때, 나오는 error 인데 다음과 같은상황에서도 나온다. numpy 와 torch.Tensor 를 혼용하며 사용하다 보니 나온 오류이다. tensor.size() : tensor 의 객체 size(shape)이 나오는데, 이를 numpy 에서 그대로 사용해서, numpy.array.size() : 는 error가 난다. .. 2022. 11. 3.
[Ubuntu] Ubuntu server (20.04.5 LTS) pycharm 설치 및 즐겨찾기 생성 및 추가 1. jetbrains.com 에서 ubuntu용 pycharm을 다운받는다. (pycharm-community/professional-20xx.x.x.tar.gz) www.jetbrains.com/pycharm/download/#section=linux Download PyCharm: Python IDE for Professional Developers by JetBrains Download the latest version of PyCharm for Windows, macOS or Linux. www.jetbrains.com 2. 다운받은 폴더에 가서 압축을 풀어준다. (.gz.tar) tar -zxvf pycharm-professional-2022.2.2.tar.gz 3. 이후 pycharm 폴더안.. 2022. 9. 19.
[Ubuntu] Ubuntu server (20.04.5 LTS) hostname 변경하기 # hostname 확인 hostname # homename을 myserver로 바꾸기 hostnamectl set-hostname myserver # 재부팅 sudo reboot 이제 ~@myserver:~$ 로 변경을 할 수 있습니다. 2022. 9. 15.
[Ubuntu] Ubuntu server(20.04.5 LTS) + CUDA 11.6 + cudnn8.4.0 설치 1. ubuntu 20.04.5 설치 (Rufus) https://releases.ubuntu.com/20.04.5/?_ga=2.163840441.788706021.1663029194-1495615447.1663029194 Ubuntu 20.04.5 LTS (Focal Fossa) Select an image Ubuntu is distributed on three types of images described below. Desktop image The desktop image allows you to try Ubuntu without changing your computer at all, and at your option to install it permanently later. This type of.. 2022. 9. 13.
[DNN] VIT(vision transformer) 리뷰 및 코드구현(CIFAR10) (ICLR2021) Introduction 안녕하세요 pulluper입니다. 👏 이번 포스팅에서는 NLP에서 강력한 성능으로 기준이 된 Transformer (Self-Attention)을 vision task에 적용하여 sota(state-of-the-art)의 성능을 달성한 ICLR2021에 발표된 vision transformer에 대한 리뷰 및 구현을 해보겠습니다. vision에 주로 사용되는 convolution 없이 transformer 만으로 당시 최고의 성능을 달성하였습니다. 약 2년이 지난(2022년 9월 기준) 시기에도 88.55%의 성능으로 26위를 하였고 상위권의 모델들은 대부분 self-attention을 많이 사용했습니다. 이 포스팅의 목표는 ViT의 이해를 통한 간단한 구현입니다. 자 그럼 시작해.. 2022. 9. 11.