일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | 5 | 6 | 7 |
8 | 9 | 10 | 11 | 12 | 13 | 14 |
15 | 16 | 17 | 18 | 19 | 20 | 21 |
22 | 23 | 24 | 25 | 26 | 27 | 28 |
29 | 30 |
- Python
- WOX
- pytorch
- 생산성
- 수치해석
- Linear algebra
- 옵시디언
- 고체역학
- Dear abby
- 수식삽입
- ChatGPT
- LaTeX
- JAX
- 우분투
- matplotlib
- 논문작성법
- 텝스공부
- obsidian
- 딥러닝
- Numerical Analysis
- IEEE
- 에러기록
- MATLAB
- 논문작성
- Julia
- teps
- 인공지능
- 텝스
- Zotero
- Statics
- Today
- Total
목록프로그래밍 Programming (93)
뛰는 놈 위에 나는 공대생
JAX가 버전에 따라 조금씩 달라지는 부분이 있어서 정리해놓는 글. 1) 배열 원소 업데이트 방식 # JAX 0.3 이전 input_data_test = index_update(input_data_test, index[i,:], input_data_tmp) # JAX 0.4 input_data_test = input_data_test.at[i,:].set(input_data_tmp) 2) optimizers 0.3버전에서는 optimizer가 기본적으로 제공이 되는데 이 방식이 0.4에서는 바뀐다.
그래프를 여러개 그리는데 색깔이 설정에서 계속 동일하게 반복된다. (아래 그림 참고) 나의 경우에는 색상을 classic으로 설정해서 클래식 색상의 7가지가 반복되게 되어있다. 이게 마음에 안 들어서 살펴보다가 최신 matplotlib 버전부터는 axes.set_prop_cycle을 이용하면 색상도 편하게 다르게 할 수 있고 마커도 일정 패턴을 반복하도록 할 수 있음을 알게 되었다. 아래는 그 예시 코드로 Spectral cmap에서 내가 원하는 그래프 개수만큼을 간격을 추출해서 그래프를 그리기 전에 미리 cycler를 정의해놓으면 편하게 색상을 지정할 수 있다. import matplotlib.pyplot as plt ax = plt.subplot(111) num_lines = 30 colors = [..
(컴퓨터 지식이 부족한 사람의 서버 연결법에 대한 설명이므로 자세한 내용은 전문가 분을 참고하세요 / 참고한 글은 아래에 링크로 달아놓았습니다.) 연결 세팅은 다음과 같다. 1. 고정아이피로 할당된 공유기(IPTIME)가 존재한다. 2. 공유기에서 유선으로 연결된 나의 컴퓨터가 있다. 이 컴퓨터가 원격으로 접속할 클라이언트다. 3. 동일한 공유기에서 유선으로 연결된 서버 컴퓨터가 있다. 여기서 강조할 부분은 '같은 공유기를 쓴다'는 점이다. 만약 클라이언트와 서버 둘 다 각자의 랜선으로 연결되어 각자의 아이피를 가지고 있다면 컴퓨터의 주소인 아이피가 명확하기 때문에 중간에 있는 몇 가지 단계들을 그냥 넘어갈 수 있다. 하지만 현실적인 문제로 공유기를 통해 두 개를 연결한 경우이다. 이 경우, 공유기에 유..
MCMC sampling을 위한 라이브러리 marathon : c++ 라이브러리 c++ 라이브러리는 고려하지 않았으므로 패스 Pyro : Pyro is a universal probabilistic programming language (PPL) written in Python and supported by PyTorch on the backend. Pyro enables flexible and expressive deep probabilistic modeling, unifying the best of modern deep learning and Bayesian modeling. It was designed with these key principles Universal: Pyro can represen..
inject_hyperparams라는 함수로 optax의 optimizer를 묶어서 사용하면 hyperparams를 관찰할 수 있다. # Wrap the optimizer to inject the hyperparameters optimizer = optax.inject_hyperparams(optax.adamw)(learning_rate=schedule) def fit(params: optax.Params, optimizer: optax.GradientTransformation) -> optax.Params: opt_state = optimizer.init(params) # Since we injected hyperparams, we can access them directly here print(f'A..
JAX에서 값을 쓰다가 어려운 부분이 있으면 대체로 numpy에 있는 함수들과 비슷한 것이 많아서 찾기 쉽다. 1. NaN 값 찾기 import jax.numpy as jnp a = jnp.array([jnp.nan,1,0,jnp.nan]) x = jnp.isnan(a) print(x) >> [ True False False True] 2. +-Inf 값 찾기 import jax.numpy as jnp a = jnp.array([jnp.inf,1,0,-jnp.inf]) x = jnp.isinf(a) print(x) >> [ True False False True] 1,2번 항목을 보면 boolean array으로 나오기 때문에 위 코드에서 'a'라는 array에 대해 indexing하면 NaN값을 추출할..
데이터의 차원이 높아질 수록 개별 데이터를 확인하는 것이 어렵고 필요없는 데이터를 제거하는 것이 어려워진다. 이를 위한 다양한 방법들을 알아보기로 한다. 1. 이상치 제거 배열에서 이상치를 제거하는 함수는 MATLAB에서 R2018b 이후부터 rmoutliers로 제공하고 있다. 이상값 감지는 평균에서 3 표준편차를 초과해 떨어져있는 요소를 기준으로 한다. 기준은 평균, 중앙값 등 기준을 다양하게 잡을 수 있다. [B,TFrm,TFoutlier,L,U,C] = rmoutliers(kt_s_pred) ; # L : 하한 임계값, U : 상한 임계값, C : 중심값, TFoutlier : 이상값 표시자, TFrm : 제거된 데이터 2. 조건에 맞는 요소 출력 B = A(A>0.0) # A배열에서 0.0보다 ..
mobaXterm은 리눅스 서버와 다양한 방식으로 연결할 수 있도록 돕는 프로그램이다. (꼭 리눅스 서버와 연결하는 것은 아니지만 주로 SSH 연결을 통해 많이 사용한다. 그런데 GUI를 보면서 리눅스 서버를 사용하고 싶을 수 있다. 이전에는 Anydesk (원격접속 프로그램)를 통해서 사용했는데 무료계정이라면 여러 명이 동시에 GUI를 쓸 경우에 Anydesk를 쓰는 것이 불가능하기 때문에 다른 VNC 서버/클라이언트 프로그램을 찾아봐야 한다. 이전 글에서 TurboVNC를 설치하는 방법에 대해 다뤘었다. TurboViewer가 있으면 사용가능한데 굳이 Turbo Viewer 없이 mobaXterm으로도 접속 가능하다. 여기서는 TurboVNC를 통해 mobaXterm으로 접속하는 방법을 소개한다. (..
JAX 사용시 발생할 수 있는 문제점이다. JAX의 최신버전은 가장 최신의 CUDA, cuDNN 버전을 요구하기 때문에 다음과 같은 에러를 만나게 된다. E external/xla/xla/stream_executor/cuda/cuda_dnn.cc:433] Loaded runtime CuDNN library: 8.8.0 but source was compiled with: 8.9.1. CuDNN library needs to have matching major version and equal or higher minor version. If using a binary install, upgr CUDA12.1 버전에 cuDNN 8.9.1버전(현재 기준으로 가장 최신버전은 8.9.2인데 보통 요구하는 cuDN..
아래 그림을 보면 u(그림 상에서는 y축에 해당함)가 15일 때 x가 -15인 형태로 3d plot을 그렸다. 그런데 내가 원하는 것은 u가 15일 때, x도 15인 형태로 그리고 싶을 수 있다. 즉, x축을 반전시키거나 y축을 반전시키고 싶을 수 있다. plot할 때 X,Y축 자체의 순서를 바꿔서 plot하는 것도 방법일 수 있지만 3d plot은 X,Y,Z가 모두 행렬로 되어있기 때문에 이를 신경써서 바꿔주는 게 쉽지 않다. 따라서 다음 방법을 쓴다. figure ; s = surf(X,U,g1_true); s.EdgeColor = 'none'; xlabel('x') ; ylabel('u') ; set(gca,'Ydir','reverse') % 축 반전 다음과 같이 한 축을 반전시킨 다음에 돌려가면서..