본문 바로가기

DL

(20)
밑러닝 - (3) 신경망의 학습신경망을 학습시킨다는 것은 Training Data를 활용해 신경망의 파라미터(Weight/Bias)의 최적값을 구할 수 있도록 하는 것이다. 신경망 학습(Deep Learning)을 통한 방식은 사람이 직접 세운 규칙을 통해 문제를 해결하는 Rule-Based 방식, 그리고 사람이 고안한 알고리즘과 기계가 데이터로부터 특징을 포착하는 방식을 결합한 기계 학습(Machine Learning) 방식과는 다르게온전히 학습 데이터로 부터 신경망이 스스로 학습해 문제를 해결해 나가는 방식이라는 점에서 차이점이 존재한다.데이터신경망을 학습시키기 위한 데이터를 훈련 데이터(training data)라고 하고, 훈련 데이터를 통해 학습된 신경망의 성능 평가를 위한 데이터셋을 시험 데이터(test data..
밑러닝 - (2) 퍼셉트론의 조합만으로도 어떤 복잡한 함수도 표현 가능하지만('Universal Approximation Theorem'),퍼셉트론의 조합만을 사용하기에는 적절한 parameter(가중치, 임계치)를 일일이 설정해줘야 한다는 단점이 존재한다. 이러한 단점에 대해, 신경망은 적절한 parameter값을 학습을 통해 스스로 찾아가는 성질을 가져 대처 가능하다.신경망신경망은 크게 세가지 구조로 이루어져 있다.입력층(Input Layer)Input으로 들어오는 데이터에 해당되는 Layer은닉층(Hidden Layer)Input 데이터에 대한 가중합(+Activation Fucntion) 과정이 거쳐 만들어진 결과에 해당되는 Layer출력층(Output Layer)하나의 신경망에서 모든 과정을 거쳐 최종적으로 계산..
Gradient Clipping What is Gradient ClippingGradient Clipping이란 Exploding Gradient를 방지하기 위한 테크닉의 하나이다. Backpropagation을 통해 계산된 Gradient를 $g$, threshold를 $c$라고 했을 때, Gradient Clipping에 대한 수식은 다음과 같다. $ g \leftarrow c \cdot \frac{g}{\vert\vert g \vert\vert} \text{, if } \vert\vert g \vert\vert \geq c$ $ \frac{g}{\vert\vert g \vert\vert} $는 $g$를 L2 Norm이 1인 unit vector로 만들어주기 때문에새로 만들어진 $g$는 L2 Norm을 c로 제한해주게 되고, 따라서..
[Pytorch] GPU elapsed time / torch.cuda.Event() 딥러닝 모델이 실행되는 시간을 체크하려면 일반적으로 사용하는import timestart = time.time()output = model(input_tensor)elapsed_time = time.time()-start혹은import timestart = time.perf_counter()output = model(input_tensor)end = time.perf_counter()다음과 같은 방식으로 접근하는 것은 정확하지 않다. 그 이유는 우리가 일반적으로 딥러닝 모델에 대한 연산을 진행할 때 GPU를 사용하기 때문이다. 딥러닝 모델에 대한 연산이 진행되는 개괄적인 흐름은 다음과 같다.CPU에서 모델 학습/추론에 사용될 input tensor를 준비준비된 input tensor를 모델에서 연산이때 ..
[Pytorch] torch.Tensor.expand() & torch.Tensor.repeat() torch 사용 중에 expand와 repeat을 몇번 접하게 되었는데, 사용하게 되면 어떤 결과가 나오는지에 대한 naive한 느낌은 있지만 명확하게 기억나지 않을때가 있어서 정리해놓으려고 한다. torch.Tensor.expand()https://pytorch.org/docs/stable/generated/torch.Tensor.expand.html#torch.Tensor.expand torch.Tensor.expand — PyTorch 2.4 documentationShortcutspytorch.orgPytorch 공식문서에 따르면, expand 메소드는 '차원 수가 1인 dim에 대해 그 수를 늘려준 view를 반환한다' 라고 설명되어있다.import torchtensor = torch.tenso..
[논문리뷰] GDSRec : Graph-Based Decentralized Collaborative Filtering for Social Recommendation https://arxiv.org/abs/2205.09948 GDSRec: Graph-Based Decentralized Collaborative Filtering for Social RecommendationGenerating recommendations based on user-item interactions and user-user social relations is a common use case in web-based systems. These connections can be naturally represented as graph-structured data and thus utilizing graph neural networks (GNNs) forarxiv.orgAbstract & Intro해..
[논문리뷰] Graph Neural Networks for Social Recommendation https://arxiv.org/abs/1902.07243 Graph Neural Networks for Social RecommendationIn recent years, Graph Neural Networks (GNNs), which can naturally integrate node information and topological structure, have been demonstrated to be powerful in learning on graph data. These advantages of GNNs provide great potential to advance social recarxiv.orgAbstract & Intro구조적으로 데이터의 node information과 위상학적 구조를..
Word2Vec 단어를 numerical vector로 나타내기 위한 대표적인 word embedding 방법에는 Word2Vec이 존재한다. 이 외에도 단어별로 TF-IDF를 계산한 값을 해당 단어를 대표하는 Vector로 사용하는 것도 가능하지만, 이는 단순히 단어별 빈도수를 통해 계산하는 방식이므로 하나의 문장에서 각 단어의 의미를 대표하는 numerical vector로 사용할 수 있는지에 대해 의문이 들 수 있다. Word2Vec은 위 사진과 같이 각 단어를 의미하는 vector간의 수치적 연산을 통해 새로운 단어를 표현해낼수 있도록 한다.Word2Vec의 알고리즘Word2Vec의 알고리즘은 크게 두가지 방식이 존재한다.CBOW(Continuous Bag Of Words)Skip-gram두가지 방식 모두 기본적..