전체 글 37

Batch Size와 모델 성능의 상관관계

Batch Normalization 위 수식을 자세히 알 필요는 없고, 미니배치의 평균, 분산을 이용하여 값을 구한다는 것만 알면 된다. 관심이 간다면 아래 Reference에 링크해뒀으니 논문을 읽어봐도 좋을 것이다. 그래서 결론은 다음과 같다. 결국 Batch Normalization(이하 배치 정규화)는 미니배치의 평균, 분산에 영향을 받는다. 평균, 분산은 미니배치의 크기에 따라 달라지므로 Batch Size에 따라 미니배치의 평균, 분산이 변한다는 것. 따라서 Batch Size는 배치 정규화에 영향을 미친다. 즉, Batch Size에 따라 모델의 성능이 달라질 수 있다! Batch Size 정리 Batch Size가 커질수록.. Batch Size가 작아질수록.. 노이즈 ↓ 노이즈 ↑ 일반화..

ML & DL/Tips 2024.03.13

[Python] type()과 isinstance()의 차이

type() vs isinstance() type() 객체의 클래스 타입을 확인하는 함수 객체의 클래스를 반환 정확한 클래스 타입을 비교 → 상속 관계에 있는 경우에도 정확한 타입이 일치해야 'True'를 반환 isinstance() 객체가 특정 클래스의 인스턴스인지 여부를 확인하는 함수 객체가 해당 클래스의 인스턴스이면 'True', 그렇지 않으면 'False'를 반환 상속 관계만을 고려하여 'True'를 반환할 수 있음 예시 class A: pass class B(A): pass obj_b = B() print(type(obj_b) is A) # False print(type(obj_b) is B) # True print(isinstance(obj_b, A)) # True print(isinstanc..

Python 2023.08.23

M1 Mac에 psycopg2 설치하는 방법 (pip install psycopg2)

PostgreSQL을 Python과 함께 사용하기 위한 psycopg2 패키지를 M1 Mac에 성공적으로 설치하기 위한 문서 시스템 환경 Chip : Apple M1 Pro OS : MacOS Ventura 13.4.1(22F82) Memory : 16GB 1. Homebrew 설치 필자의 경우, Intel Mac → M1 Mac으로 교체하면서 Homebrew PATH가 달라져서 재설치하였음. Github Install Native Homebrew on Apple Silicon M1 Install Native Homebrew on Apple Silicon M1. GitHub Gist: instantly share code, notes, and snippets. gist.github.com 다음 명령어로 ..

Error 2023.08.16

Grounded Segment Anything(Grounded SAM)을 사용한 auto-labeling (autodistill)

Grounded Segment Anything을 이용해 auto-labeling을 해보자. 이후 해당 데이터로 YOLOv8 학습까지 진행해본다. 공식 github https://github.com/autodistill/autodistill GitHub - autodistill/autodistill: Images to inference with no labeling (use foundation models to train supervised models) Images to inference with no labeling (use foundation models to train supervised models) - GitHub - autodistill/autodistill: Images to inferenc..

ML & DL 2023.06.23

[Airflow] API기반 DAG Trigger 하기

- DAG예시 - slack으로 메세지를 보내는 간단한 작업을 수행 사용 가능한 API 목록 Airflow REST API airflow.apache.org 1. Auth 설정 1-1. 컨테이너 생성 시 설정 (docker-compose.yaml) AIRFLOW__API__AUTH_BACKENDS 환경 변수 추가 Airflow 2 버전의 기본값은 외부에서 접근 불가 id, pw를 입력하여 접근 가능하도록 basic_auth로 변경 1-2. 컨테이너 내부에서 설정 컨테이너 접속 docker exec -it /bin/bash airflow.cfg 파일 변경 vim airflow.cfg auth_backends = airflow.api.auth.backend.basic_auth로 변경 2. DAG 작성 im..

Apache Airflow 2023.06.22

Slack Webhook(API) 사용하여 메세지 보내기

1. Slack에서 Incoming WebHooks 추가 2. 메시지를 보낼 채널 설정 3. 웹후크 URL 복사 URL 형식은 다음과 같다. 4. 메세지 전송을 위한 코드 작성 (python) import json import requests def send_message(url): data = {"text": "hello"} # {"text": "slack에 보낼 메시지"} req = requests.post( url=url, data=json.dumps(data) ) if __name__ == '__main__': url = '' # 3에서 복사한 URL 붙여넣기 send_message(url) 결과

Etc. 2023.06.21

[Python] requirements.txt에 링크 넣기

mmcv 설치 하는데 삽질을 너무 많이 해서 정리할 겸 올리는 글. requirements.txt에 다음과 같이 넣어준다. (반드시 PyTorch, CUDA 버전에 맞게 설치할 것) mmcv-full==1.7.0 --find-links https://download.openmmlab.com/mmcv/dist/cu117/torch1.13/index.html mmcv가 아닌 다른 패키지를 설치하는 경우에도 동일한 방법으로 사용 가능 이후 다음 명령어로 설치를 진행한다. pip install -r requirements.txt

Python 2023.06.07

[논문 리뷰] DRÆM – A discriminatively trained reconstruction embedding for surface anomaly detection

Introduction 표면 이상 탐지(surface anomaly detection)는 정상적인 형태에서 벗어난 이미지 영역의 위치를 찾는 것. 일반적인 이상 탐지는정상적인 학습 이미지 세트와 크게 다른 이미지를 찾는 것. 표면 이상 탐지는 이미지 픽셀의 작은 부분만을 차지하며 일반적으로 학습 이미지 세트 분포와 유사 DRÆM (Discriminative joint Reconstruction Anomaly Embedding Method) DRÆM은 다음 두 가지 sub-network로 구성 된다. Reconstructive sub-network 정상 이미지만 학습 Discriminative sub-network 원본 이미지와 재구성된 이미지의 결합 모양에 대한 판별을 학습→ 생성 방식(auto-enco..

Papers Review 2022.12.12