728x90 반응형 Python181 [DL] PyTorch-Hook PyTorch의 hook은Neural Network 내부의 계산 과정을 관찰하거나,특정 시점에서 개입할 수 있도록 해주는 기능 (사실은 function 또는 instance method임).PyTorch에서는 Hook을 사용하여forward 중간 출력,backward 에서의 gradient, 또는 입력 값 자체를 가로채어 확인하거나 수정할 수 있음.Hook이 제대로 동작하기 위해선 forward를 직접 호출해선 안됨. 2024.04.12 - [Python] - [PyTorch] Custom Model 과 torch.nn.Module의 메서드들. [PyTorch] Custom Model 과 torch.nn.Module의 메서드들.Custom Model 만들기0. nn.Module torch.nn.Modul.. 2025. 4. 10. [DL] torch.nn.Linear 에 대하여 torch.nn.Linear는 PyTorch에서 선형 변환(linear transformation)을 수행하는 핵심 Module임. 다음의 이름으로도 불림.Fully Connected Layer (FC Layer)Dense LayerConstructor (생성자)torch.nn.Linear( in_features, out_features, bias=True,) TensorFlow의 Dense와 유사하나, activation등을 내장하고 있지 않음.파라미터설명in_featuresinput tensor의 마지막 차원 크기 (int)out_featuresoutput tensor의 마지막 차원 크기 (int)biasbias 사용 여부 (기본값: True)수학적 정의linear module은 .. 2025. 4. 10. [PyTorch] torch.save 와 torch.load - tensor 위주 PyTorch에서 tensor 저장 및 불러오기: torch.save와 torch.load 사용법PyTorch에서는 학습된 모델과 개별 tensor나 여러 tensor들의 집합을 저장하고 불러올 수 있음.이 문서에서는 torch.save와 torch.load 함수를 사용하여 tensor를 저장하고 불러오는 방법을 소개함. 모델 저장 및 로드는 다음을 참고2024.05.16 - [분류 전체보기] - [DL] Torch: Save and Load Model [DL] Torch: Save and Load ModelTorch: Save and Load ModelPyTorch에서 model을 저장하는 방법은 크게 두 가지임.모델의 Parameters (= weights and bias)를 저장 (Structure.. 2025. 4. 8. [Py] 연습문제-carriage return + time.sleep time.sleep 함수와 carriage return을 이용한 간단한 프로그래스바.import timel = ["-","/","|","\\"]t = len(l)def dp_progressbar(): for i in range(100): idx = i%t prog = int(i//10) print(f"progressing... {l[idx]} : {'='*prog}{i:03d}%",end="\r") time.sleep(.1) print(f"progressing... - : {'='*10}100%") dp_progressbar() https://youtu.be/MsuQxjFmis8 2025. 4. 7. [OpenCV] macOS에서 Qt 지원하도록 빌드. conda-forge에서 opencv를 설치하면 Qt를 지원하도록 빌드된 버전이 설치되었던 걸로 기억하는데...macOS에서 최근 버전들은 Qt를 지원을 하지 않는다: 사실 Qt가 무겁긴 해서 걷어낸 거 같긴한데... 2년 전 작성한 코드에서 Qt관련 부분(opencv의 High-Level GUI 기능)을 다 걷어내려니... ==;;https://dsaint31.tistory.com/480 [OpenCV] imshow 창설정 및 종료 처리 (x버튼 처리)imshow 창설정 및 종료 처리 (x버튼 처리)창 설정 관련 arguments 및 options cv2.namedWindow를 통해 미리 창에 대한 title을 지정하여 놓을 수 있음.cv2.namedWindow('image', cv2.WINDOW_NO.. 2025. 4. 5. [Py] collections.ChainMap 1. ChainMap 이란?ChainMap은 Python의 collections 모듈에서 제공하는 클래스로,여러 매핑(딕셔너리 등)을 단일 뷰로 그룹화하는 기능을 제공.ChainMap은 여러 딕셔너리를 연결(chain)하여 마치 하나의 딕셔너리처럼 사용 가능한 자료구조. 내부적으로 매핑 목록을 유지하면서 이들을 함께 검색하는 구조임.2023.07.11 - [Python] - [Python] dictionary (Mapping type) : basic [Python] dictionary (Mapping type) : basicdictionary (dict)Python에서 dictionary는key-value pair를 item으로 가지는unorderedmutablecollection임.set과 함께 cur.. 2025. 4. 4. 이전 1 2 3 4 ··· 31 다음 728x90 반응형