1. Hold-out Hold-out 방법은 데이터를 train, test set으로 나누고 train set에서 학습된 모델을 test set에서 성능을 평가하는 방식이다(held-out method라고도 함) 2. Cross-validation Cross-validation은 k-fold cross validation이라고도 하며, hold-out 방법을 k번 시행하되 매번 새로운 train/test set으로 진행하는 방식이다. 아래 그림에서 처럼 모든 데이터셋이 test set으로 사용될 때 까지 돌린다. * Hold-out vs Cross-validation Hold-out은 데이터셋이 매우 크고 시간이 없거나 PoC 컨셉으로 모델을 테스트해볼 때 유용하다. Cross-validation은 시간..
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$,..
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 버전은 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를 사용하기 위해 먼저 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..
Linux 계열에서 pkill을 사용하면 여러 프로세스를 동시에 종료시킬 수 있다. 다음과 같이 3개의 파이썬 스크립트가 돌고 있다고 하자. 이때 pkill -f [파일이름 또는 사용자명]로 다음과 같이 한번에 종료시킬 수 있다. [참고] https://unix.stackexchange.com/questions/57605/i-want-to-kill-all-processes-that-result-from-the-following-command
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 '..
Bio Statistics 분야에서 많이 활용되는 개념인 Propensity Score에 대해서 정리하고자 한다. 0. Propensity Score가 필요한 상황 Clinical research 분야에서 Randomized Controlled Trials(RCT)는 꽤 중요한 개념이다. 어떤 집단 A에 treatment에 대한 효과를 통계적으로 검증한다고 했을 때, 가장 이상적인 방법은 집단 A를 반으로 나눠 한쪽은 control group으로, 한쪽은 treatment를 진행한 group으로 나눠 수치를 얻어내는 것이다. 하지만 의료 분야에서는 현실적이지 않을 뿐더러 윤리적으로도 수행할 수 없는 경우가 많다. 흡연자에 대한 treatment를 검증하고자 할 때, 강제적으로 흡연을 시킬 수 없으니 말이..
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..
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..
port를 사용하고 있는 pid를 찾고 싶을 때가 있다. 이때 사용할 수 있는 명령어는 ss, netset, lsof가 있다. $ sudo ss -lptn 'sport = :80' State Local Address:Port Peer Address:Port LISTEN 127.0.0.1:80 *:* users:(("nginx",pid=125004,fd=12)) LISTEN ::1:80 :::* users:(("nginx",pid=125004,fd=11)) $ sudo netstat -nlp | grep :80 tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN 125004/nginx $ sudo lsof -n -i :80 | grep LISTEN nginx 125004 nginx 3u IPv..
우분투에서 ps -ef | grep python으로 실행중인 프로세스를 찾으면 아래와 같이 뜬다. user@user-System-Product-Name:~/user$ ps -ef | grep python user 5821 1 1 May16 ? 06:26:54 python -u hello.py 이때 실행중인 파일의 경로를 pid로 찾기 위해서는 다음과 같은 방법들이 있다. 1) pwdx pwdx 로 찾으면 다음과 같이 뜬다. user@user-System-Product-Name:~/user$ pwdx 5821 5821: /home/user 2) lsof lsof -p | grep cwd로 찾으면 다음과 같이 뜬다. user@user-System-Product-Name:~/user$ lsof -p 5821 ..
최근에 Docker 버전이 24으로 업데이트 된 후 아래와 같은 에러메세지가 뜨면서 실행이 안되는 문제가 발생하였다. Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running? 아래와 같은 과정으로 해결하였다. 1. Docker 서비스 종료 아래 명령어로 docker 서비스를 모두 종료한다. sudo systemctl stop docker sudo systemctl stop docker.socket sudo systemctl stop containerd 2. daemon.json 파일 확인 cat /etc/docker/daemon.json으로 파일 내용을 확인해보면 다음과 같이 되어있었다...
David Silver 교수님의 강의 내용을 정리하고자 한다(링크). 0. Introduction In the last lecture we approximated the value or action-value function using parameter $\theta$. Then policy was generated directly from the value function(e.g. $\epsilon$-greedy) $$\begin{array}{rcl} V_{\theta} & \approx &V^{\pi}(s) \\ Q_{\theta}(s,a) & \approx & Q^{\pi}(s,a) \end{array}$$ In this lecture we will directly parametrize the po..