[PyTorch] 개별 파라미터 learning rate 다르게 설정 및 learning rate 확인
·
연구 Research/인공지능 Artificial Intelligent
코드 안에 네트워크가 2개가 있고 이 2개의 네트워크를 각각 다른 learning rate로 학습하고 싶을 때 사용하는 코드다. 아래와 같이 개별로 learning rate를 설정하면 net2 안에 있는 파라미터는 0.001로 학습되고 net1 안에 있는 파라미터는 0.01로 학습된다. optimizer = optim.Adam([ {'params': func.net1.parameters()}, {'params': func.net2.parameters(), 'lr': 0.001} ], lr=0.01) optimizer.param_groups[0]['capturable'] = True print(optimizer.param_groups[0]['lr']) print(optimizer.param_groups[1..
[MATLAB] Figure 위치를 코드로 옮기기
·
프로그래밍 Programming/매트랩 MATLAB
figure를 여러 개 그릴 때 figure가 겹쳐있어서 일일이 다 옮겨줘야하는 불편함이 있었다. 이 경우에 사용할 수 있는 함수가 movegui라는 함수이다. figure 핸들을 받아서 f = figure(1); movegui(f, 'south'); 와 같이 해도 되고 figure 핸들을 받지 않더라도 movegui(방향)만 사용하면 현재 figure 또는 콜백 figure를 옮겨준다. 예: movegui(f,[150 -50]) 예: movegui('west') 위의 같은 형태로 위치를 지정할 수 있다. 1. 직접 위치 지정 (이는 원래 figure 생성할 때도 수행할 수 있다) [x y]의 경우네는 x위치, y위치를 지정하는 것이다. x위치는 화면 왼쪽으로 부터 얼마나 떨어졌는지를 나타내고 y위치는 ..
[SciPy] ValueError: One of the requested xi is out of bounds in dimension 0
·
기타
scipy에 있는 scipy.interpolate.RegularGridInterpolator를 쓸 때 발생했던 오류이다. 코드를 좀 살펴보면 내가 interpolation하기 위해 넣은 값이 내삽을 위해 지정된 값 범위에서 벗어날 때 return하는 오류이다. 예를 들어 나는 x=[0,1,2,3,4]일 때의 y값을 넣어놨는데 만약 x=5.5값을 넣으면 범위 밖에 벗어나므로 처리할 수 없다. ValueError: One of the requested xi is out of bounds in dimension 0 나의 경우에는 내가 x값을 잘못 넣었기 때문에 이런 일이 일어난 거지만 만약 외삽(extrapolate)을 원하는 경우라면 다음과 같이 bounds_error = False로 지정하고 fill_va..
[Dear abby] 230207
·
영어 공부 English Study/글 Article
Grandparents Make Little Effort To See Grandkids DEAR ABBY: I'm 33 with a wonderful husband and amazing kids, ages 4 and 6. I have a close bond with my parents. We live in a city about 80 miles from them. It seems like we are always the ones to do the visiting, and I have to practically beg them to visit me for one overnight visit a year. My house is smaller than theirs, but we offer up our bedr..
[에러기록] ImportError: cannot import name 'index_update' from 'jax.ops'
·
기타
from jax.ops import index_update, index = index_update(, index[], ) % example u = index_update(u, index[0, :], g(t)) 다음 코드를 실행할 때 발생하는 문제이다. JAX 0.3.2부터는 jax.opt.index_update, jax.opt.index가 사라졌기 때문에 이 기능을 쓰기 위해서는 jax와 jaxlib을 0.3.2 버전 전으로 돌려야 한다. 혹은 저 위의 기능은 특정 인덱스에 배열 값을 바꾸는 코드이기 때문에 x = x.at[idx].set(y) 와 같이 특정 인덱스에 y라는 값으로 바꾸는 코드로 바꿔줄 수 있다.
[JAX] Windows에서도 JAX 사용하기
·
연구 Research/인공지능 Artificial Intelligent
JAX는 아직 리눅스에서밖에 사용이 안된다. 그래서 윈도우에서 돌릴 수 있는 방법을 찾아보았는데 최신 버전은 불가능하고 예전 버전은 가능하다. JAX가 아직 초기이다보니 버전마다 많이 바뀌어서 불편한 점이 있지만 일단 시도한 경험을 공유한다. 아래 링크를 들어가면 대략적인 instruction을 알 수 있다. https://github.com/cloudhan/jax-windows-builder GitHub - cloudhan/jax-windows-builder: A community supported Windows build for jax. A community supported Windows build for jax. Contribute to cloudhan/jax-windows-builder deve..
[에러기록] assertionerror: if capturable=false, state_steps should not be cuda tensors.
·
연구 Research/인공지능 Artificial Intelligent
pytorch 안에서 adam을 쓸 때 자꾸 위와 같은 에러가 떠서 이를 위해 optimizer = optim.Adam(func.parameters(), lr=args.lr) optimizer.param_groups[0]['capturable'] = True 다음과 같이 'capturable'을 true로 바꿔줘야했다. 그런데 다른 사람들의 라이브러리를 쓰다보면 optimizer가 라이브러리 안에 포함되어있어서 위와 같은 코드를 넣어주기 힘든 경우가 발생했다. 따라서 아래와 같이 가상환경 안에 있는 코드에 접근하여서 에러가 나는 부분을 주석처리해주었다. 이렇게 하는 이유는 실제로 위의 error가 코드 성능에 악영향을 미치지 않기 때문이다. params 및 state_steps이 CUDA tensor일 ..
[Jupyter notebook] 내가 설정한 주피터 노트북 테마
·
프로그래밍 Programming/파이썬 Python
Jupyter notebook에서 테마를 설정하였다. 기본적으로 jupyter notebook theme라는 유명한 개발자 분의 툴을 쓰면 되는데 사용할 때는 터미널에서 다음과 같은 명령을 해주어야 한다. 나는 기본으로 있는 fira code를 사용하였다. jt -f firacode -fs 14 -altp -tf firacode -tfs 14 -nf firacode -nfs 14 -cellw 90% -T -N -ofs 12 -cursc r
[Dear abby] 230206
·
영어 공부 English Study/글 Article
Dad Must Endure Entitled Teen's Frequent Tantrums DEAR ABBY: I'm writing on behalf of my partner of more than 10 years. He has three daughters ages 23, 20 and 16. While he's close to two of them, his youngest distances herself when she doesn't get what she wants or disagrees with his point of view on something. Eight months ago, she stopped talking to him because he badmouthed a boy band she lik..
[논문작성] AIAA 양식 정리 (3) Mathematics
·
기타/논문작성 Writing
저번에 이어서 쓰는 AIAA 양식 정리. 1. Mathematics Symbol 익숙하지 않은 기호를 피할 것 MathType이나 다른 수식 작성 소프트웨어를 사용할 것. equation을 image로 변환하지 말 것 1. 언더바 심볼을 피하라 2. 여러 개의 dot accents를 피하라. 최대 2개 3. barred symbol을 쓸 때 한 글자 변수는 bar accent $\bar{a}$ 와 같이 쓰고 여러 개 글자를 쓸 때는 $\overline{abc}$ 로 표기 4. 각 수식 표현을 분리할 때 구두점을 사용하는데 같은 line 선상에 쓴다. 그리고 각 라인마다는 구두점을 찍지 않는다. 방정식 끝나고 온점을 찍지 마라. Subscripts & superscripts 여러 layer로 sub-, s..