107 lines
296 KiB
Plaintext
107 lines
296 KiB
Plaintext
|
{
|
||
|
"cells": [
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": 10,
|
||
|
"metadata": {},
|
||
|
"outputs": [
|
||
|
{
|
||
|
"data": {
|
||
|
"image/png": "iVBORw0KGgoAAAANSUhEUgAABW0AAAMWCAYAAACKoqSLAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjkuMCwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy80BEi2AAAACXBIWXMAAA9hAAAPYQGoP6dpAAEAAElEQVR4nOzdd1xT1/sH8E8GSdhblI0bcOOqWgGt1g6te7RVUdva2qn221qt29qh1Q5rtVrAUbVaR7XWWgfixL1xsRRENoSVEJLc3x/8cpuYQYDAZTzv18tXQ+655z735sktPDk5h8cwDANCCCGEEEIIIYQQQggh9QKf6wAIIYQQQgghhBBCCCGE/IeKtoQQQgghhBBCCCGEEFKPUNGWEEIIIYQQQgghhBBC6hEq2hJCCCGEEEIIIYQQQkg9QkVbQgghhBBCCCGEEEIIqUeoaEsIIYQQQgghhBBCCCH1CBVtCSGEEEIIIYQQQgghpB6hoi0hhBBCCCGEEEIIIYTUI0KuAyANj1qtRnp6Ouzt7cHj8bgOhxBCCCGEEEIIIYSQBoFhGBQVFcHT0xN8vvHxtFS0JVWWnp4OHx8frsMghBBCCCGEEEIIIaRBSk1Nhbe3t9HtVLQlVWZvbw+gIrkcHBw4jobUNyUlJYiPj0dQUBBsbW25Doc0QZSDhGuUg4RrlIOEa5SDhEuUf4RrlIOkMoWFhfDx8WHra8ZQ0ZZUmWZKBAcHByraEj1isRitW7eGi4sLxGIx1+GQJohykHCNcpBwjXKQcI1ykHCJ8o9wjXKQmKuyKUd5DMMwdRQLaSQKCwvh6OgIqVRKRVtCCCGEEEIIIYQQQsxkbl3N+Gy3hBBSDSqVCkVFRVCpVFyHQpooykHCNcpBwjXKQcI1ykHCJco/wjXKQWIpVLQlhFiUXC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Uf4RrlIPEUqhoS4gWNx979nFOWjGHkRBCCCGEEEIag6lTpwIAysvL2aKsIQcPHmRHh2r2qYy/vz94PB78/f0Nbl+0aJHeokyXL1/GlClT0LJlS0gkEri6uiI8PBzR0dGVrnbf2Bbu0l40TrMQXXp6OhYsWICuXbvC1dXV4CJ1OTk5iIqKwuTJk9GlSxc4OTnBysoKLi4u6NKlCz788EPcuXOn0uNHRESwxzc01YX2YnqLFi1i45s7dy6Cg4NhZ2cHBwcHdO3aFUuWLEFRkemBR9qLdBkSHR3NbtdM23D//n28//77aNu2LWxsbODk5IRnnnkG33//PRQKRaXnCAA3b97EG2+8gYCAAEgkEjRv3hxhYWGIjIxkc64+5tbx48cRERGB1q1bw87ODra2tmjdujUmT56MY8eOmdXHqVOnMHXqVAQGBsLe3h5WVlZo1qwZgoKCMGTIECxduhT37983uv/BgwcxYcIEtG7dGra2thCLxWjRogU6duyIV155BStXrkRaWpqlTpnUMzQ9AiFaXL1sAR4AhkbaVpdMJkNiYiJatWoFa2trrsMhTRDlIOEa5SDhGuUg4ZpmTlGxWAw+n8YJBQYGonfv3oiLi0NUVBRmzpxpsJ1magQvLy8MHjwYW7dutXgsX3/9NebNm6ezKFpZWRlOnDiBEydO4M8//8SuXbsgFDbcUoEm/yorQBty5MgRjB8/Hnl5eUbbJCUloV27dgbnG87Pz0d+fj6uX7+OH3/8EYsXL2bnYraEf//9FxMmTNCL79q1a7h27Rp+++03HD9+HF5eXhY53pYtWzB9+nTIZDL2OZlMhri4OMTFxeH333/HP//8AwcHB6N9/PDDD5g9e7bO9crMzERmZiZiY2Px22+/mZzPmgulpaWYOHEi9uzZo7ctMTERiYmJ2Lx5M0aOHIktW7bAxsZGp41arYZMJsOsWbMMzqWcnZ2N7Oxs3LlzB4cPH8b58+fx119/6bSRyWQYN24cDhw4oLd/RkYGMjIycOvWLez
|
||
|
"text/plain": [
|
||
|
"<Figure size 1400x800 with 1 Axes>"
|
||
|
]
|
||
|
},
|
||
|
"metadata": {},
|
||
|
"output_type": "display_data"
|
||
|
}
|
||
|
],
|
||
|
"source": [
|
||
|
"import pandas as pd\n",
|
||
|
"import matplotlib.pyplot as plt\n",
|
||
|
"\n",
|
||
|
"# Excel 파일 로드\n",
|
||
|
"file_path = 'training_loss.xlsx'\n",
|
||
|
"data = pd.read_excel(file_path, header=[0, 1]) # 첫번째 행은 모델, 두번째 행은 속성\n",
|
||
|
"\n",
|
||
|
"# Step이 300 이상인 데이터만 선택\n",
|
||
|
"limit = 300\n",
|
||
|
"\n",
|
||
|
"# 모델별로 Step, Training Loss, Validation Loss 컬럼 추출\n",
|
||
|
"models = list(set([col[0] for col in data.columns if 'Step' in col[1]]))\n",
|
||
|
"\n",
|
||
|
"# 그래프 생성\n",
|
||
|
"fig, ax1 = plt.subplots(figsize=(14, 8))\n",
|
||
|
"\n",
|
||
|
"# 색상 설정 (필요한 색상 수만큼 확장 가능)\n",
|
||
|
"colors = ['#d62728', '#1f77b4', '#2ca02c', '#ff7f0e', '#9467bd', '#17becf', '#bcbd22']\n",
|
||
|
"\n",
|
||
|
"# 각 모델에 대해 Training Loss와 Validation Loss를 플롯\n",
|
||
|
"for i, model in enumerate(models):\n",
|
||
|
" # 모델별로 Step, Training Loss, Validation Loss 데이터 추출\n",
|
||
|
" steps = data[(model, 'Step')]\n",
|
||
|
" training_loss = data[(model, 'Training Loss')]\n",
|
||
|
" validation_loss = data[(model, 'Validation Loss')]\n",
|
||
|
" \n",
|
||
|
" # Step이 300 이상인 데이터만 필터링\n",
|
||
|
" steps_filtered = steps[steps >= limit]\n",
|
||
|
" training_loss_filtered = training_loss[steps >= limit]\n",
|
||
|
" validation_loss_filtered = validation_loss[steps >= limit]\n",
|
||
|
" \n",
|
||
|
" # Training Loss는 실선, Validation Loss는 점선으로 플롯 (각 모델에 대해 다른 색상 사용)\n",
|
||
|
" ax1.plot(steps_filtered, training_loss_filtered, label=f'{model} - Training Loss', color=colors[i % len(colors)], linestyle='-', linewidth=2, zorder=1)\n",
|
||
|
" ax1.plot(steps_filtered, validation_loss_filtered, label=f'{model} - Validation Loss', color=colors[i % len(colors)], linestyle='--', linewidth=2, zorder=1)\n",
|
||
|
" \n",
|
||
|
" # 가장 작은 Validation Loss 지점에 마크 표시 (역삼각형, 투명도 추가, 테두리 추가, zorder 높게 설정)\n",
|
||
|
" min_val_loss_idx = validation_loss_filtered.idxmin()\n",
|
||
|
" min_step = steps_filtered.loc[min_val_loss_idx]\n",
|
||
|
" min_val_loss = validation_loss_filtered.loc[min_val_loss_idx]\n",
|
||
|
" \n",
|
||
|
" # 역삼각형 마커에 테두리 추가 및 zorder 설정\n",
|
||
|
" ax1.scatter(min_step, min_val_loss, color=colors[i % len(colors)], marker='v', s=100, alpha=0.7, edgecolors='black', linewidth=1.5, zorder=3)\n",
|
||
|
"\n",
|
||
|
"# 공통의 범례 항목으로 흰색 역삼각형 표시 추가\n",
|
||
|
"ax1.scatter([], [], color='white', marker='v', s=100, edgecolors='black', linewidth=1.5, label='Min Val Loss', zorder=3)\n",
|
||
|
"\n",
|
||
|
"# X축과 Y축 그리드 추가\n",
|
||
|
"ax1.grid(True, which='both', linestyle='--', linewidth=1.0, alpha=0.7)\n",
|
||
|
"\n",
|
||
|
"# 글자 크기 조정\n",
|
||
|
"ax1.set_xlabel('Step', fontsize=24)\n",
|
||
|
"ax1.set_ylabel('Loss', fontsize=24)\n",
|
||
|
"ax1.tick_params(axis='both', which='major', labelsize=21)\n",
|
||
|
"\n",
|
||
|
"# 범례 설정\n",
|
||
|
"ax1.legend(loc='upper right', fontsize=22)\n",
|
||
|
"\n",
|
||
|
"# 여백 조정\n",
|
||
|
"plt.tight_layout()\n",
|
||
|
"\n",
|
||
|
"# 그래프 표시\n",
|
||
|
"plt.show()\n"
|
||
|
]
|
||
|
}
|
||
|
],
|
||
|
"metadata": {
|
||
|
"kernelspec": {
|
||
|
"display_name": "torch",
|
||
|
"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.14"
|
||
|
}
|
||
|
},
|
||
|
"nbformat": 4,
|
||
|
"nbformat_minor": 2
|
||
|
}
|