[에러기록] 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일 ..
[인공지능] Windows 기준 CUDA & cuDNN 최신 버전 설치 (CUDA 11.6 이상)
·
연구 Research/인공지능 Artificial Intelligent
OS : Windows11 최근에 다시 CUDA와 cuDNN를 설치하면서 예전에 썼던 설치법과 조금 다른 부분이 있어서 여기에 소개한다. 예전에는 CUDA 버전에 따른 cuDNN 버전을 찾아야해서 번거로움이 있었는데 CUDA 11.6부터는 cuDNN이 통일된 것으로 보인다. 그래서 이제는 cuDNN 용 폴더를 하나 만들어서 그 파일 안에 보관하고, 이에 대한 경로를 추가하면 된다. (이전 글을 보면 cuDNN 파일을 CUDA 폴더 안에 복사하라고 얘기했었다.)  이 방법도 물론 통하지만 새로운 manual에서는 다르게 설명한다. 다음 링크에서 매뉴얼을 읽어본 바에 따르면 방법은 다음과 같다.  1) cuDNN 파일을 다운 cuDNN zip 파일에서 알집을 풀면 다음을 확인할 수 있다.  각각의 폴더에는 ..
[PyTorch] retain_graph = True라고 했음에도 backward 문제가 발생하는 경우
·
연구 Research/인공지능 Artificial Intelligent
RuntimeError: Trying to backward through the graph a second time (or directly access saved tensors after they have already been freed). Saved intermediate values of the graph are freed when you call .backward() or autograd.grad(). Specify retain_graph=True if you need to backward through the graph a second time or if you need to access saved tensors after calling backward. 위와 같은 에러는 한 번 모델에서 for..
[PyTorch] 모델 저장/불러오기 및 모델 수정하기
·
연구 Research/인공지능 Artificial Intelligent
빠른 학습을 위하여 이미 학습된 파라미터를 가지고 오고 싶을 때가 있다. 그래서 이 글에서는 기본적인 모델 저장, 불어오기 뿐 아니라 내가 좀 더 커스터마이징 할 수 있는 방법에 대해서 고민했다. 1. 모델 저장 파이토치 매뉴얼에서는 다음과 같이 모델을 저장하라고 권한다. PATH = '(모델이름).pth' torch.save(modelA.state_dict(), PATH) 이렇게 해서 pth 파일을 저장할 수 있다. state_dict는 내부 상태 사전(internal state dictionary)으로서 학습된 모델의 매개변수를 저장한다. modelA.state_dict()를 출력하면 다음과 같은 형태가 나온다. 위의 OrderedDict는 dictionary 자료형인데 파이썬에서 순서 정렬에 유리하..
[제어] Uncertainty 개념
·
연구 Research/제어 Control
요즘 uncertainty에 대해 고민을 하다가 알게 되는 내용을 기록하고자 쓰는 글. 1. Matched uncertainty Matched uncertainty : the uncertain terms enter the state equation at the same point as the control input, which allows the control to dominate their effect (Khalil, nonlinear control) 2. Structured uncertainty & Unstructured uncertainty Uncertainty의 다른 분류로 structured and unstructured uncertainty로 나눌 수 있다. Structured uncerta..
[비선형제어] Diffeomorphism
·
연구 Research/제어 Control
x라는 변수를 z라는 변수로 mapping할 때 식으로 다음과 같이 표현한다고 하자. $z=T(x)$ 흔히 선형대수학에서는 transformation matrix $T$로 표현하면 $z=Tx$로 similarity transformation을 수행할 수 있었다. (T가 nonsingular일 때) 비선형 mapping인 경우에는 $z=T(x)$에서 T가 invertible해야한다. 이 말을 다르게 하면 inverse map $x=T^{-1}(z)$가 모든 $z\in T(D)$ (D는 T의 domain)에서 존재해야한다는 뜻과 같다. 보통 T가 함수로 표현되기 때문에 T의 미분은 z와 x에 대하여 continuously differentiable해야한다. A continuously differentiabl..
[제어] eigenvalue와 stability 분석 (algebraic multiplicity와 geometric multiplicity의 차이)
·
연구 Research/제어 Control
Khalil의 nonlinear control에서 선형 시스템의 stability를 다음과 같은 theorem으로 정리한다. $\textbf{Theorem 3.1}$ The equilibruim point $x=0$ of $\dot{x}=Ax$ is stable if and only if all eigenvalues of A satisfy $Re[\lambda_{i}]\leq 0 $ and for every eigenvalue with $Re[\lambda_{i}]=0$ and algebraic multiplicity $q_{i}\geq 2 $, $\operatorname{rank}(A-\lambda_{i})=n-q_{i}$, where $n$ is the dimension of $x$. The equi..
[제어] Lyapunov stability theorem 증명
·
연구 Research/제어 Control
조금이라도 제어에 대해 공부한 사람이라면 한 번쯤 들어볼 법한, Lyapunov stability theorem. 이 Lyapunov stability theorem에 대한 증명은 Khalil의 Nonlinear control에 잘 나와있다. 처음에 그냥 읽으면 무슨 소리인지 납득이 안되는 부분이 있는 것 같아서, 증명을 이해하는 연결다리를 써보고자 글을 쓴다. Lyapunov stability theorem $\text{If there is }V(x)\text{ such that }V(0)=0\text{ and }V(x)>0,\; \forall x\in D\text{ with }x\neq 0$ $\dot{V}(x)\leq 0\; \forall x\in D$ $\text{then the origin is..
[MATLAB] 3차원 vector field diagram과 시뮬레이션 결과 mapping
·
연구 Research/제어 Control
저번 글에서 phase plane과 vector field diagram을 그려주는 MATLAB app을 소개했었다. 그런데 이 프로그램은 2차원에서만 가능하기 때문에 변수가 하나 더 늘면 구현이 불가능했다. 그래서 간단하게 3차원 공간에서 벡터 필드를 그리고, 실제 초기 조건에 대하여 시뮬레이션까지 수행하여서 그려보는 코드를 작성하였다. 1. 시스템 $\dot{x}=-x+y$ $\dot{y}=-0.1x^3-y-10\sin x$ $\dot{z}=y-z$ 다음과 같은 시스템이 있다고 할 때 interval = pi/2 ; start_pt = -pi ; end_pt = -start_pt ; [x1,y1,z1] = meshgrid(start_pt:interval:end_pt, start_pt:interval:..
[제어] Phase portrait 프로그램과 예시
·
연구 Research/제어 Control
Autonomous 시스템에 대하여 Phase portrait (state plane, phase plane)을 그려주는 프로그램이 있어서 수업시간에 배운 내용을 그려보았다. 프로그램의 UI가 잘 되어있어서 추천하는 바이다. 1. Tunnel-diode circuit system 다음 시스템은 Tunnel-diode circuit 시스템을 다룬 것이며 이 시스템은 $x_{1}=v_{C}, x_{2}=i_{L}$ 일 때 $$ \begin{gathered} \dot{x}_1=0.5\left[-h\left(x_1\right)+x_2\right] \\ \dot{x}_2=0.2\left(-x_1-1.5 x_2+1.2\right) \\ h\left(x_1\right)=17.76 x_1-103.79 x_1^2+229..