Python
-
import torch.nn as nn 딥러닝을 배우면서 pytorch를 쓰기 시작하면 다음과 같은 코드를 많이 봤을 것이다. torch.nn은 neural network (인공 신경망) 에 사용되는 다양한 클래스와 모듈이 포함되어있다. 예를 들어 위 코드에서도 보면 torch.nn을 import 하고 Linear, ReLU 등을 사용하는 것을 볼 수 있다. https://pytorch.org/docs/stable/nn.html torch.nn — PyTorch 2.0 documentation Shortcuts pytorch.org 파이토치 공식 문서를 보면 딥러닝에서 사용되는 다양한 layer, container 등을 확인 할 수 있다.
[Python] import torch.nn as nn 역할import torch.nn as nn 딥러닝을 배우면서 pytorch를 쓰기 시작하면 다음과 같은 코드를 많이 봤을 것이다. torch.nn은 neural network (인공 신경망) 에 사용되는 다양한 클래스와 모듈이 포함되어있다. 예를 들어 위 코드에서도 보면 torch.nn을 import 하고 Linear, ReLU 등을 사용하는 것을 볼 수 있다. https://pytorch.org/docs/stable/nn.html torch.nn — PyTorch 2.0 documentation Shortcuts pytorch.org 파이토치 공식 문서를 보면 딥러닝에서 사용되는 다양한 layer, container 등을 확인 할 수 있다.
2023.08.14 -
pytorch를 사용하다 보면 torch.no_grad()라는 걸 종종 확인할 수 있다. torch.no_grad()의 역할은 딥러닝 모델을 test, 즉 inference를 할 때에는 backpropagation이 진행되지 않는다. 즉, gradient 연산을 전혀 사용하지 않는다. 그렇기 때문에 굳이 torch에서 auto gradient 연산이 돌아가게 켜 둘 필요가 없다. 따라서 위 pytorch 공식 문서에 나와있는 것 처럼 gradient 연산을 꺼서 불필요한 메모리 사용량을 줄이는 것이 목적이다. https://pytorch.org/docs/stable/generated/torch.no_grad.html no_grad — PyTorch 2.0 documentation Shortcuts pyt..
[Python] torch.no_grad() 역할pytorch를 사용하다 보면 torch.no_grad()라는 걸 종종 확인할 수 있다. torch.no_grad()의 역할은 딥러닝 모델을 test, 즉 inference를 할 때에는 backpropagation이 진행되지 않는다. 즉, gradient 연산을 전혀 사용하지 않는다. 그렇기 때문에 굳이 torch에서 auto gradient 연산이 돌아가게 켜 둘 필요가 없다. 따라서 위 pytorch 공식 문서에 나와있는 것 처럼 gradient 연산을 꺼서 불필요한 메모리 사용량을 줄이는 것이 목적이다. https://pytorch.org/docs/stable/generated/torch.no_grad.html no_grad — PyTorch 2.0 documentation Shortcuts pyt..
2023.08.14 -
오류 코드 RuntimeError: PytorchStreamReader failed reading zip archive: failed finding central directory semgentation 모델을 mmdet에서 돌릴 때 발생한 에러 코드이다. 해당 오류는 학습한 weight 파일이 깨졌을 경우 발생한다. 해결 방법 학습된 weight 파일들이 여러개 있다면 다른 weight 파일을 가지고 inference를 돌려본다.
RuntimeError: PytorchStreamReader failed reading zip archive: failed finding central directory오류 코드 RuntimeError: PytorchStreamReader failed reading zip archive: failed finding central directory semgentation 모델을 mmdet에서 돌릴 때 발생한 에러 코드이다. 해당 오류는 학습한 weight 파일이 깨졌을 경우 발생한다. 해결 방법 학습된 weight 파일들이 여러개 있다면 다른 weight 파일을 가지고 inference를 돌려본다.
2023.08.11 -
오류 코드 Traceback (most recent call last): File "C:\Users\labadmin\Desktop\0810\mmdetection-2.x\train.py", line 88, in model = build_detector(cfg.model, train_cfg=cfg.get('train_cfg'), test_cfg=cfg.get('test_cfg')) NameError: name 'build_detector' is not defined mmdet을 사용할 때 모듈을 불러오지 않아서 발생 해결 방법 from mmdet.models import build_detector
Traceback (most recent call last): File "C:\Users\labadmin\Desktop\0810\mmdetection-2.x\train.py", line 88, in <module> model = build_detector(cfg.model, train_cfg=cfg.get('train_cfg'), test_cfg=cfg.get('test_cfg'))NameError: name 'build_detector' i..오류 코드 Traceback (most recent call last): File "C:\Users\labadmin\Desktop\0810\mmdetection-2.x\train.py", line 88, in model = build_detector(cfg.model, train_cfg=cfg.get('train_cfg'), test_cfg=cfg.get('test_cfg')) NameError: name 'build_detector' is not defined mmdet을 사용할 때 모듈을 불러오지 않아서 발생 해결 방법 from mmdet.models import build_detector
2023.08.10 -
문제 상황 VScode에 세팅값이 변경되었는지 다음과 같이 터미널에서 자동으로 줄바꿈이 되어 출력이 되었다. 해결 방법 Alt + z 를 입력하면 아래와 같이 스크롤이 활성화 되면서 자동 줄바꿈이 꺼진다. 마찬가지로 자동 줄바꿈을 하고자 하면 Alt + z를 입력한다.
VSCode 터미널 출력 자동 줄바꿈 설정 변경 단축키문제 상황 VScode에 세팅값이 변경되었는지 다음과 같이 터미널에서 자동으로 줄바꿈이 되어 출력이 되었다. 해결 방법 Alt + z 를 입력하면 아래와 같이 스크롤이 활성화 되면서 자동 줄바꿈이 꺼진다. 마찬가지로 자동 줄바꿈을 하고자 하면 Alt + z를 입력한다.
2023.08.08 -
Python에서urdf를 바로 사용하는 방법 관련 패키지 설치하기 우선 pip을 이용해 urdfy를 설치한다. pip install urdfpy 사용 예시 from urdfpy import URDF robot = URDF.load("./planar3b.urdf") urdfpy를 불러와 기존에 작성해둔 urdf 파일을 불러온다. vscode에서 urdf 작성을 간편하고 빠르게 해주는 extension 설치는 아래 링크를 참고하면 된다. https://barrer.tistory.com/95 [ROS] vscode urdf 자동완성 extension URDF ROS를 사용할 때 urdf를 정말 많이 사용한다, 이 때 VScode를 사용해서 코드를 작성하는 경우 xml 형식의 코드를 짜는데 은근 실수를 많이한다..
[ROS] python에서 urdf 사용하기 urdfpyPython에서urdf를 바로 사용하는 방법 관련 패키지 설치하기 우선 pip을 이용해 urdfy를 설치한다. pip install urdfpy 사용 예시 from urdfpy import URDF robot = URDF.load("./planar3b.urdf") urdfpy를 불러와 기존에 작성해둔 urdf 파일을 불러온다. vscode에서 urdf 작성을 간편하고 빠르게 해주는 extension 설치는 아래 링크를 참고하면 된다. https://barrer.tistory.com/95 [ROS] vscode urdf 자동완성 extension URDF ROS를 사용할 때 urdf를 정말 많이 사용한다, 이 때 VScode를 사용해서 코드를 작성하는 경우 xml 형식의 코드를 짜는데 은근 실수를 많이한다..
2023.08.06