You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

387 lines
30 KiB
Plaintext

{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# SOM (Self Organizing Map, 자기조직화지도)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### 개요\n",
"* 비지도학습 중 하나로, 대뇌피질의 시각피질의 학습 과정을 모델화한 인공신경망으로써 자율 학습에 의한 클러스터링을 수행하는 알고리즘"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### 역사\n",
"* 1980년대 후반에 핀란드의 컴퓨터 과학자 Teuvo Kohonen에 의해 개발\n",
"* SOM은 분류, 군집화, 데이터 시각화 등 다양한 분야에서 사용되며, 인공신경망 분야에서 가장 성공적인 알고리즘 중 하나로 평가됨\n",
"* 초기에는 이미지 인식과 음성 인식 분야에서 주로 사용되었으나 현재는 데이터 분석 등의 다양한 분야에서도 사용됨"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### 특징\n",
"* 인간의 뇌에서 발견된 \"자기 조직화\" 원리를 모델링하여 입력 데이터의 유사성을 기반으로 뉴런들을 2D 혹은 3D 지도상에 배치함\n",
"* Topological Ordering (위상적 순서)에 따라 지도상에서 인접한 뉴런들이 입력 데이터의 유사성을 반영하여 군집화(Clusturing)함\n",
"입력 데이터에 대한 어떤 사전 정보나 라벨이 없이도, 데이터가 가지고 있는 패턴과 특성을 스스로 학습하고 이를 지도상으로 표현함\n",
"* 주로 데이터의 시각화 및 차원 축소에 사용되며, 입력 데이터의 분포를 파악하여 그룹화하여 시각적으로 표현하므로, 복잡한 데이터를 시각적으로 이해하고 분석하는 데 도움을 줌"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### 주요 용어\n",
"* 클러스터링(clustering): 데이터의 유사성에 기초하여 데이터를 몇몇의 그룹으로 분류하는 기법\n",
"* 입력층(input layer): 입력 벡터를 입력받는 층\n",
"* 경쟁층(competitive layer): 입력 벡터의 특성에 따라 입력 벡터가 한 점으로 클러스터링 되는 층\n",
"* 가중치(weight): 인공신경망에서 가중치는 각 입력 값에 대한 입력 값의 중요도를 값을 말함\n",
"* 노드(node): 경쟁층에서 입력 벡터들이 서로의 유사성에 의해 모이는 하나의 영역"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"![SOM Layer Structure](./images/SOM1.png)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### 알고리즘\n",
"1-1) 가중치 행렬 각 원소의 값을 임의의 0보다 크고 1보다 작은 값으로 초기화\n",
"\n",
"2-1) 입력 벡터와 경쟁층에 존재하는 j\n",
"개의 노드에 대해 입력 벡터와 노드 간의 거리 Dij\n",
"를 계산\n",
"\n",
"2-2) 현재 입력 벡터와 Dij\n",
"값이 가장 작은 경쟁층의 노드를 선택\n",
"\n",
"2-3) 해당 노드의 가중치와 이웃 노드의 가중치를 수정\n",
"\n",
"5-1) 현재 입력 벡터가 마지막 입력 벡터라면 다음 과정으로 이동하고, 그렇지 않다면 과정 2로 돌아간다\n",
"\n",
"6-1) 현재 반복 횟수가 최대 반복 횟수라면 알고리즘을 종료\n",
"\n",
"6-2) 현재 반복 횟수가 최대 반복 횟수가 아니면 현재 입력 벡터를 처음 입력 벡터로 설정하고 과정 2로 돌아간다"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"![SOM Algorithm](./images/SOM2.png)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### 참고\n",
"https://untitledtblog.tistory.com/5"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### SOM 예제 코드"
]
},
{
"cell_type": "code",
"execution_count": 69,
"metadata": {},
"outputs": [],
"source": [
"import numpy as np\n",
"import matplotlib.pyplot as plt"
]
},
{
"cell_type": "code",
"execution_count": 70,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"array([[0.76959259, 0.03105338],\n",
" [0.91933906, 0.8980492 ],\n",
" [0.74919767, 0.46775453],\n",
" [0.66010482, 0.70532455],\n",
" [0.07347433, 0.31437638],\n",
" [0.52162755, 0.75475037],\n",
" [0.07618824, 0.5595569 ],\n",
" [0.37694104, 0.88389 ],\n",
" [0.59261356, 0.49140373],\n",
" [0.11567152, 0.32084966],\n",
" [0.81627506, 0.7724125 ],\n",
" [0.7708446 , 0.98667885],\n",
" [0.57884267, 0.92658698],\n",
" [0.48815338, 0.04666865],\n",
" [0.07971729, 0.56926156],\n",
" [0.93371788, 0.20473364],\n",
" [0.71241481, 0.68994675],\n",
" [0.69855141, 0.55690579],\n",
" [0.87081581, 0.48218263],\n",
" [0.73239668, 0.47015934],\n",
" [0.48234206, 0.38374233],\n",
" [0.51407113, 0.3925697 ],\n",
" [0.97608349, 0.58044996],\n",
" [0.67676596, 0.51393561],\n",
" [0.37059459, 0.99168193],\n",
" [0.17015263, 0.17250751],\n",
" [0.6980668 , 0.47156525],\n",
" [0.9674704 , 0.29847506],\n",
" [0.85297608, 0.15389296],\n",
" [0.99135256, 0.95353731],\n",
" [0.75749781, 0.05744834],\n",
" [0.5850026 , 0.69425312],\n",
" [0.35572734, 0.77261987],\n",
" [0.96259553, 0.10738437],\n",
" [0.0178066 , 0.68856146],\n",
" [0.78219693, 0.6523648 ],\n",
" [0.18744908, 0.73438952],\n",
" [0.19713904, 0.56662014],\n",
" [0.11656314, 0.50708698],\n",
" [0.33800968, 0.03634445],\n",
" [0.64802194, 0.90416709],\n",
" [0.7668028 , 0.7619133 ],\n",
" [0.55338936, 0.78892134],\n",
" [0.20716839, 0.95280491],\n",
" [0.47688275, 0.30063862],\n",
" [0.22233577, 0.02612442],\n",
" [0.21021643, 0.66526042],\n",
" [0.87039248, 0.75634555],\n",
" [0.91421121, 0.60350262],\n",
" [0.32014712, 0.61909491],\n",
" [0.03320721, 0.69900356],\n",
" [0.0806021 , 0.68826953],\n",
" [0.52828811, 0.78636528],\n",
" [0.49048742, 0.60616199],\n",
" [0.07021355, 0.64982408],\n",
" [0.21773879, 0.55571391],\n",
" [0.02119119, 0.62099936],\n",
" [0.75589808, 0.88236869],\n",
" [0.99479197, 0.98599938],\n",
" [0.35444256, 0.84292181],\n",
" [0.90941177, 0.30758414],\n",
" [0.87616741, 0.18060184],\n",
" [0.22973575, 0.50353087],\n",
" [0.33569227, 0.82710827],\n",
" [0.03575231, 0.86915894],\n",
" [0.59710596, 0.91274408],\n",
" [0.61854338, 0.06007 ],\n",
" [0.69497861, 0.26505075],\n",
" [0.80347052, 0.93909288],\n",
" [0.8998602 , 0.34498986],\n",
" [0.96359265, 0.66780466],\n",
" [0.6180583 , 0.36145526],\n",
" [0.22507441, 0.24977 ],\n",
" [0.82067222, 0.65858647],\n",
" [0.26533719, 0.50457457],\n",
" [0.20615695, 0.52028333],\n",
" [0.78530409, 0.23287443],\n",
" [0.81894409, 0.32542015],\n",
" [0.66607148, 0.0717416 ],\n",
" [0.15435642, 0.57144805],\n",
" [0.60568206, 0.62824524],\n",
" [0.40981871, 0.51319754],\n",
" [0.14660118, 0.14759826],\n",
" [0.89091339, 0.12148139],\n",
" [0.48159329, 0.76667587],\n",
" [0.73766975, 0.76237422],\n",
" [0.32449576, 0.11193535],\n",
" [0.05351455, 0.37051478],\n",
" [0.15487227, 0.0884276 ],\n",
" [0.40902546, 0.73216362],\n",
" [0.6227993 , 0.54298886],\n",
" [0.70489165, 0.60729615],\n",
" [0.43506953, 0.26510733],\n",
" [0.17818975, 0.41551925],\n",
" [0.07820619, 0.31987945],\n",
" [0.27646196, 0.00825832],\n",
" [0.30999502, 0.67284126],\n",
" [0.6372436 , 0.48780002],\n",
" [0.66962877, 0.44225145],\n",
" [0.48185839, 0.17663244]])"
]
},
"execution_count": 70,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"# 입력 데이터 생성\n",
"data = np.random.rand(100, 2)\n",
"# data = np.array([[0.8, 0.0064],\n",
"# [0.12, 0.2848],\n",
"# [0.24, 0.7472],\n",
"# [0.68, 0.3488]])\n",
"data"
]
},
{
"cell_type": "code",
"execution_count": 71,
"metadata": {},
"outputs": [],
"source": [
"# SOM 파라미터 설정\n",
"map_width = 10\n",
"map_height = 10\n",
"lr = 0.1\n",
"num_iterations = 1000\n",
"# map_width = 2\n",
"# map_height = 2\n",
"# lr = 0.1\n",
"# num_iterations = 1000"
]
},
{
"cell_type": "code",
"execution_count": 78,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"(10, 10, 2)\n"
]
},
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAhYAAAENCAYAAABTviwWAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjcuMCwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy88F64QAAAACXBIWXMAAA9hAAAPYQGoP6dpAAAZMklEQVR4nO3de3DU9b3G8Se7MbsBknBRkEiAQK0BgorcqrFejkwRQaEXa9tgERy0mhSQVgV7gFomBFsP4hEEZQricAlozVSdUQ8nHuAwBbkJAzpyKVQjCMjRJuG2Ibvf88cZ0pMKJBu+3938dt+vmd8f7Ow++5kl+eTJbze7KcYYIwAAAAt88R4AAAAkDooFAACwhmIBAACsoVgAAABrKBYAAMAaigUAALCGYgEAAKyhWAAAAGtSY32HkUhEhw8fVkZGhlJSUmJ990DSM8aopqZG2dnZ8vm88bsFewOIv6bujpgXi8OHDysnJyfWdwvgn1RWVqpLly7xHqNJ2BtAy9HY7oh5scjIyJAk9bp/mvxpQev5/pD1SEnSV9dF3ARLSu1wxklu5n+1cpIrSX/Pc/dO8KtGznOS++O3ip3kSlLP1086yT3ynQzrmeHaM9q76Hf134tecG7WKRW3KtjG/trKD1Raz5Qk4/DZ5idfu99J7rYxf3SSK0n9X33QWfZ9w9c7yd3ys287yZUk4+js255ftXeSGzl9Rod/PbvR3RHzYnHuNKY/LeimWDj6eedLd1csfI5+/rt4fM/xBd0VizYZbpaxL+ju8Uj1h53k+gPuZvbSUwrnZg22SXVSLFoH/dYzJSnisFj4HX09Zzr6/pPcfg8G21zmJDfVF3CSK0nG5+Z70Jfu7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FVVdXm4kTJ5quXbuaYDBoevToYX7zm9+YUCgU79ESkpd2RyLsDWO8sTvYG7HDx6YDAABrWtxrLAAAgHdRLAAAgDUUCwAAYA3FAgAAWEOxAAAA1lAsAACANRQLAABgDcUCAABYQ7EAAADWUCwAAIA1FAsAAGANxQIAAFjzv+S19TZnuoF5AAAAAElFTkSuQmCC",
"text/plain": [
"<Figure size 640x480 with 2 Axes>"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"# SOM 초기화\n",
"som_map = np.random.rand(map_width, map_height, 2)\n",
"print(som_map.shape)\n",
"fig, (ax1, ax2) = plt.subplots(1, 2)\n",
"ax1.imshow(som_map[:,:,0])\n",
"ax2.imshow(som_map[:,:,1])\n",
"plt.show()"
]
},
{
"cell_type": "code",
"execution_count": 73,
"metadata": {},
"outputs": [],
"source": [
"# SOM 학습\n",
"for i in range(num_iterations):\n",
" # 랜덤한 입력 데이터 선택\n",
" input_data = data[np.random.choice(data.shape[0])]\n",
" \n",
" # 가장 유사한 뉴런 찾기\n",
" # 3D som_map과 input_data의 차이^2를 구하여 z축으로 모두 합한 거리\n",
" distances = np.sum((som_map - input_data) ** 2, axis=2) \n",
" # 위에서 구한 z축의 거리들 중 가장 작은 뉴런\n",
" winner = np.argmin(distances)\n",
" # 3D z축에서 선택된 가장 작은 뉴런을 2D map으로 맵핑한 좌표\n",
" x, y = np.unravel_index(winner, (map_width, map_height))\n",
" \n",
" # 학습률 계산\n",
" learning_rate = lr * (1 - i/num_iterations)\n",
" \n",
" # 뉴런 가중치 업데이트\n",
" for j in range(map_width):\n",
" for k in range(map_height):\n",
" dist = np.sqrt((x-j)**2 + (y-k)**2)\n",
" if dist < 3:\n",
" som_map[j, k] += learning_rate * (input_data - som_map[j, k])"
]
},
{
"cell_type": "code",
"execution_count": 74,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"(10, 10, 2)\n"
]
},
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAh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DDkqQ5c+bo0KFDeuqpp8bsgHjhhRe0efNmbdmyRbNmzdLBgwe1fPly1dTUjNmekXtBmBtSMGcHcyPH8v1ZzL9KpVImEomYbdu2DVr+3e9+13zjG9/IT1M+NDc3m2nTppmOjo58t3JB27ZtM5JMJBIZuEkyoVDIRCIRk8lk8t3iedXV1Znvf//7g5b96le/MjU1NXnqaHjTpk0zTzzxxKBla9asMZ/73Ofy1FFhCvLsCMrcMCaYs4O5kVtj7jsW0WhUN9xwg9ra2gaWZbNZtbW16aabbspjZxdmjNGSJUu0bds2/eEPf1B9fX2+W7qgW265RW+99ZYOHjw4cGtsbFRTU5MOHjyoSCSS7xbPa/78+Z/5OV57e7umT5+ep46G19vbq3B48K4WiUSUzWbz1FFhCuLsCNrckII5O5gbOZbvZHM+W7duNbFYzDz77LPmnXfeMT/4wQ/MhAkTTFdXV75bG9K9995rqqqqzI4dO8xHH300cOvt7c13ayM21r/Zbczff95WUlJiWlpazJEjR8zmzZtNRUWF+fWvf53v1oa0aNEic/nllw/8bOw3v/mNmTJlivnZz36W79YKTtBmRyHMDWPG/uxgbuTWmAwWxhjz+OOPm7q6OhONRs28efPM7t27893SBUk6723jxo35bm3ExvpwOOd3v/udaWhoMLFYzMycOdOsX78+3y1dUDKZNMuWLTN1dXWmrKzMXHHFFebnP/+5SaVS+W6tIAVpdhTC3DAmGLODuZE7XDYdAABYM+a+YwEAAIKLYAEAAKwhWAAAAGsIFgAAwBqCBQAAsIZgAQAArCFYAAAAawgWAADAGoIFAACwhmABAACsIVgAAABrCBYAAMCa/wNGq/kfY7C4fQAAAABJRU5ErkJggg==",
"text/plain": [
"<Figure size 640x480 with 2 Axes>"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"# SOM 시각화\n",
"print(som_map.shape)\n",
"fig, (ax1, ax2) = plt.subplots(1, 2)\n",
"ax1.imshow(som_map[:,:,0])\n",
"ax2.imshow(som_map[:,:,1])\n",
"plt.show()"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### 참고\n",
"ChatGPT"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.10.6 (main, Mar 10 2023, 10:55:28) [GCC 11.3.0]"
},
"orig_nbformat": 4,
"vscode": {
"interpreter": {
"hash": "916dbcbb3f70747c44a77c7bcd40155683ae19c65e1c03b4aa3499c5328201f1"
}
}
},
"nbformat": 4,
"nbformat_minor": 2
}