분류 전체보기
-
합성 곱(Convolution)카테고리 없음 2024. 3. 12. 08:25
1.소개 합성 곱은 CNN같은 AI 인공지능에 활용되는 공학 수학에서의 연산이다. 본 포스팅은 합성 곱의 대략적인 개념에 대해 이해하는 것을 목표로 한다. 2.개념 f(x) * h(x)=integral_{-inf,inf} f(t)h(r-t)로 연속 함수에서의 합성곱이다. 여기서 CNN에서 쓰는 이산적인 연산은 적분이 아닌 시그마로 일정한 간격을 두고 곱을 수행한다. 3.응용 오차 역전파는 다중 퍼셉트론 구조에서 손실을 최대로 줄이는 방향으로 가는 일종의 경사하강법이다. 이때 활성함수를 주로 지나는데, 여기서 ReLu같은 활성함수들로 합성곱을 진행하게 된다.
-
Transformer카테고리 없음 2024. 3. 11. 20:23
최근 NLP에서 빠지지않고 들어가는 Transformer에 대해서 리뷰해보겠다. Attention is all you need(2017)를 참조하여 작성하였다. 1-1.I/O->Encoder input data가 인코더로 들어가는 과정이다. 이때 문장들의 sequences가 주어졌을 때, 가중치 행렬에 대하여 내적을 수행한다.(embedding) 그 결과 각 문장들의 토큰들이 학습시 임베딩 레이어를 통해 벡터로 들어가게 된다. 1-2.장점 이로 인한 장점으로는 seq2seq는 RNN을 사용하여 순차적 데이터 처리과정을 밟게 되는데 반해 transformer는 한 번에 내적을 수행함으로 기울기 소실 문제가 해결되게 된다. 1-3.문제점과 해결책 하지만 문장내에서 순서가 중요하고, 각 토큰에 유일한 값과 토..
-
Dynamic Programming(동적 계획법)알고리즘/동적 계획법 2022. 9. 6. 22:45
도입 오늘은 동적계획법(DP)에 대해 소개 해보겠다. 먼저 필자는 아직도 동적 계획법을 잘 못한다. Dynamic Programming이라는 어려운 이름에 ㅎㄷㄷ 할 수 있지만, 당시 연구실에서 연구비 많이 받을려고, 이런 이름으로 지었다고 한다. 1. 동적계획법 정의 먼저 동적계획법은 어떠한 문제를 다른 부분 문제로 나누는 것을 의미한다. 예를 들어 대표적인 예는 피보나치 수열이다. Fibo n = Fibo n-1 + Fibo n-2 로 나타낼 수 있다. Fibo n이라는 문제를 부분적으로 나눈 것이다. 이 경우에 n부터 시작해 함수 호출이 약 2배씩 증가함으로 총 O(2^N)에 근사하는 시간복잡도를 가지지만, 메모이제이션이라는 기법을 사용하면 간단해진다. 2. 메모이제이션 우리는 4번째 항의 피보나치..
-
2022 한국 정보 올림피아드 1,2차 후기일상 2022. 8. 1. 16:16
실력이 부족해서 후기라 할 것도 없었다. PS는 작년 1월달 부터 하기 시작했다. 1차 1차를 보는데 필기가 엄청 어려워서 원래 180점 정도를 예상했지만,(거짓말,최대공약수)문제를 틀리고, 확률과 통계 관련 문제를 틀려서 100점 초반대가 나왔다. 실기는 2번 문제는 손도 못 댔고, 1번 피하자 문제를 푸는데, 일단 다 바꿔보는 브루트 포스로 50점을 긁었고, 누적합을 사용해 O(n)만에 풀려고 했고, 로직은 맞았다. 하지만 int 자료형을 넘는 경우가 있어 그것도 모르고 있다가. 동상을 받게 되었다. 2차 1번 먼저 1번 문제의 서브테스크 1번을 풀려고 했다. 근데 계속해서 0점이 나와 당황해 3번 4번 문제의 1번 서브테스크만 긁고 다시 돌아왔는데, 갑자기 등차수열에서 원소가 정수란것을 이용해서 O..
-
Greedy(욕심쟁이)알고리즘/그리디 2022. 7. 31. 10:08
흔히 풀 수 있고, 어려운 것은 어려운 그리디에 대해 말해보겠다. 그리디는 단편적인 큰 코스트를 취하는 방법이다. 1.그리디의 예시 빠르게 본론으로 넘어가겠다. 백문이 불아일견이라 했다. 우리가 1원 5원 10원의 동전들이 무수히 많다고 하자. 자연수인 N이 주어질때 동전들의 합으로 N을 만들어야하는 상황에 사용되는 동전들의 개수를 최소화 시킬려면 어떻게 해야할까? 2.해답 어짜피 1원 5개를 쓰일 상황에선 5원을 하나 쓰는게 이득이고 5원 2개 쓰일빠엔 10원 하나를 쓰는게 이득이다. 고로 10원을 N에서 계속 빼다가 5원을 빼고 1원을 빼는 것. 가장 큰 액수부터 빼는게 이 문제의 답이다. 이러한 것 처럼 그리디는 단순히 그 순간만을 위한 최선의 선택을 하는 알고리즘이다. 정당성에 관한 부분은 그 문..
-
시간복잡도알고리즘/기법,기초 2022. 7. 31. 09:52
시간복잡도는 프로그램의 수행시간을 다항식으로 나타내는 것이다. 시간복잡도는 시간제한이 있는 OJ사이트나 코딩 테스트,대회 등에서 중요한 요소이다. 하지만 대부분의 사람들은 시간복잡도를 그냥 대충 계산하는 경향이 있다.(사실 그래도 된다.) 그러나 필자는 깊이 있는 문제 풀이를 위해 시간복잡도가 굉장히 중요한 요소라 생각하기에 이에 대해 말해 보겠다. 1.시간복잡도 계산 그 프로그램에 있는 반복문의 반복 횟수라 봐도 문제가 없다. arr[1]과 같은 한 번에 접근 가능한 것을 O(1)의 시간복잡도를 가졌다 하고, 이는 그 프로그램의 시간복잡도에서 보통 생략된다. 예를 들어보자. n=int(input()) for i in range(n): print(i) 다음의 코드는 i가 0부터 n까지 1씩 증가하는 코드..
-
boj 2436 - 공약수문제풀이/초급 2022. 6. 28. 22:21
http://boj.kr/2436 Baekjoon Online Judge Baekjoon Online Judge 프로그래밍 문제를 풀고 온라인으로 채점받을 수 있는 곳입니다. www.acmicpc.net 문제 설명 최대 공약수와 최소 공배수 a,b가 주어질때 이를 만족하는 수 n,m의 합이 최대가 되도록 하는 문제입니다. 풀이 과정 1 n = a*n' m = a*m' a는 최대 공약수를 의미합니다. 최소 공배수는 두 수의 곱 나누기 최대 공약수 즉 b = n*m/a n,m을 치환 한다면 b = (a * n') * (a * m') / a 이므로 b = a * n' * m'입니다. 풀이 과정 2 일단 a,b의 범위가 1억까지 주어진 것을 보면 O(n)이하의 시간복잡도가 요구 됩니다. 근데 무작위로 두 수를 ..
-
boj 2609 - 최대공약수와 최소공배수문제풀이/초급 2022. 6. 26. 23:50
boj.kr/2609 2609번: 최대공약수와 최소공배수 첫째 줄에는 입력으로 주어진 두 수의 최대공약수를, 둘째 줄에는 입력으로 주어진 두 수의 최소 공배수를 출력한다. www.acmicpc.net 문제 설명 간단한 문제이다. a와 b의 최소 공배수,최대 공약수를 구하면 된다. 풀이 전 게시글에서 최소 공배수에 대해 다루었으니 최대 공약수인 gcd값을 구하는 것만 알아보자. 증명은 넘어가고 코드를 보도록 하겠다. (유클리드 호제법 - 나무위키 (namu.wiki)) 주의할 점은 a가 b보다 크도록 하고 실행해야한다. int gcd(int a,int b){ if(a%b==0)return b; else return gcd(b,a%b); } 더 간결하게 짜는 법은 이와 같다. (삼항 연산자를 사용하도록 하자..