전체 글

이것저것
Reinforcement Learning

[RL] Value Function 구체적으로 생각해보기

Markov Decision Process(MDP)에서 policy가 존재할 때 value function은 Bellman Equation으로 표현되며, 다음과 같이 두 가지가 있다. The state-value function $\color{red}v_{\pi}(s)$ of an MDP is the expected return from state $s$, and then following policy $\pi$ $$\color{black}v_{\pi}(s) = \mathbb{E}_{\pi}[G_{t}\ |\ S_{t}=s]$$ The action-value function $\color{red}q_{\pi}(s,a)$ is the expected return starting from state $s$,..

개발

Gunicorn & Uvicorn

1. Gunicorn Gunicorn은 production 레벨에서 사용할 수 있는 WSGI(Web Server Gateway Interface)로 고성능, 쉬운 배포가 특징이다. Flask, Django와 같은 프레임워크들을 서빙할 수 있다. 여러 프로세스로 서버를 돌릴 수 있으며 또한 process manager로도 동작하기 때문에 Uvicorn으로 실행된 어플리케이션을 관리할 수 있다. 2. Uvicorn Uvicorn은 ASGI(Asynchronous Server Gateway Interface) 웹 서버로 Starlette을 추상화하여 개발되었다. ASGI이기 때문에 단일 프로세스에서 비동기로 요청을 처리하기 때문에 WSGI에 비해 매우 많은 요청을 처리할 수 있다. [참고] https://te..

개발

[Nginx] 맥os에 Nginx 설치하기

맥북에서 Nginx 설치를 해보고자 한다. 맥OS 버전은 13.0 기준이다. 먼저 brew install nginx로 설치해준다. ==> Fetching nginx ==> Downloading https://ghcr.io/v2/homebrew/core/nginx/manifests/1.25.1_1 ... ==> Installing nginx ==> Pouring nginx--1.25.1_1.arm64_ventura.bottle.tar.gz ==> Caveats Docroot is: /opt/homebrew/var/www The default port has been set in /opt/homebrew/etc/nginx/nginx.conf to 8080 so that nginx can run without..

개발

[Nginx] forward & reverse proxy

Nginx를 사용하기 위해 먼저 proxy server를 이해하고자 한다. 1. Proxy Server 먼저 proxy server는 다음과 같다. A proxy server is a system or router that provides a gateway between users and the internet. Therefore, it helps prevent cyber attackers from entering a private network. It is a server, referred to as an “intermediary” because it goes between end-users and the web pages they visit online... Proxies provide a valua..

python 메모

[pkill] 여러 프로세스 동시에 종료시키기

Linux 계열에서 pkill을 사용하면 여러 프로세스를 동시에 종료시킬 수 있다. 다음과 같이 3개의 파이썬 스크립트가 돌고 있다고 하자. 이때 pkill -f [파일이름 또는 사용자명]로 다음과 같이 한번에 종료시킬 수 있다. [참고] https://unix.stackexchange.com/questions/57605/i-want-to-kill-all-processes-that-result-from-the-following-command

개발

[fastapi] logging format 설정

Fastapi에 logging을 설정하는 방법은 다음과 같이 두 가지가 있다. 1. uvicorn으로 설정 log_config = uvicorn.config.LOGGING_CONFIG log_config["formatters"]["access"]["fmt"] = "%(asctime)s - %(levelname)s - %(message)s" log_config["formatters"]["default"]["fmt"] = "%(asctime)s - %(levelname)s - %(message)s" uvicorn.run(app, log_config=log_config) 2. logger로 설정 @app.on_event("startup") async def startup_event(): logger = log..

개발

[Miniconda] CommandNotFoundError: Your shell has not been properly configured to use 'conda activate'. 에러

Ubuntu에서 Miniconda로 가상환경을 실행시킬 때 다음과 같은 에러가 뜨는 경우가 있다. CommandNotFoundError: Your shell has not been properly configured to use 'conda activate'. To initialize your shell, run $ conda init Currently supported shells are: - bash - fish - tcsh - xonsh - zsh - powershell See 'conda init --help' for more information and options. IMPORTANT: You may need to close and restart your shell after running '..

논문 및 개념 정리

Propensity Score

Bio Statistics 분야에서 많이 활용되는 개념인 Propensity Score에 대해서 정리하고자 한다. 0. Propensity Score가 필요한 상황 Clinical research 분야에서 Randomized Controlled Trials(RCT)는 꽤 중요한 개념이다. 어떤 집단 A에 treatment에 대한 효과를 통계적으로 검증한다고 했을 때, 가장 이상적인 방법은 집단 A를 반으로 나눠 한쪽은 control group으로, 한쪽은 treatment를 진행한 group으로 나눠 수치를 얻어내는 것이다. 하지만 의료 분야에서는 현실적이지 않을 뿐더러 윤리적으로도 수행할 수 없는 경우가 많다. 흡연자에 대한 treatment를 검증하고자 할 때, 강제적으로 흡연을 시킬 수 없으니 말이..

Reinforcement Learning

[RL] Introduction to Multi-Armed Bandits (1)

Reinforcement Learning 관련 내용 중 하나인 Multi-Armed Bandits(MAB)에 대한 내용을 정리하고자 한다(논문링크). The Multi-Armed Bandit problem (MAB) is a toy problem that models sequential decision tasks where the learner must simultaneously exploit their knowledge and explore unknown actions to gain knowledge for the future (exploration-exploitation tradeoff)(출처). 0. Introduction: Scope and Motivation 1) Example Multi-arm..

개발

TensorRT와 Triton

Nvidia에서 TensorRT(TRT)와 Triton Inference Server(TRTIS)에 대해 워크샵을 진행한 내용이 있어서 정리하고자 한다(워크샵 영상 및 자료 링크)(TRT Quickstart Github) 0. Introduction 모델 학습이 끝난 이후, 실제 production 환경에서 모델을 서빙할 때 필요한 부분들은 학습할 때와는 다르다. 가장 간단한 방식은 .predict()/.forward()를 실행하는 것이다. 하지만 더 속도와 TPS를 고민하고 더 좋은 방식이 없을지 생각하다 보면 다음과 같은 질문들이 떠오를 수 있다. Is there something more we can do with our model now that we don’t need to train anymo..

Fine애플
끄적끄적