File size: 3,242 Bytes
9860743
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
{
  "cells": [
    {
      "cell_type": "code",
      "execution_count": 1,
      "id": "4cd1da0e",
      "metadata": {},
      "outputs": [],
      "source": [
        "%load_ext autoreload\n",
        "%autoreload 2\n",
        "import pandas as pd\n",
        "import numpy as np\n",
        "import seaborn as sns\n",
        "import matplotlib.pyplot as plt\n",
        "from synthetic_task.plot_results import load_comp_grad_results_metrics, plot_comp_grad_metrics_vs_iter_by_ydim"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": 2,
      "id": "6f2b2dea",
      "metadata": {},
      "outputs": [],
      "source": [
        "sns.set_theme(style=\"whitegrid\", context=\"talk\")\n",
        "palette = sns.color_palette()"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": 3,
      "id": "d24a0bbc",
      "metadata": {},
      "outputs": [],
      "source": [
        "batch_size = 8\n",
        "COMP_GRAD_DIR = f\"../synthetic_results_compare_grad_{batch_size}\"\n",
        "\n",
        "METHODS = [\n",
        "    \"ffocp_eq\",\n",
        "]\n",
        "METHODS_LEGEND = {\n",
        "    \"ffocp_eq\": \"FFOCP\",\n",
        "}\n",
        "\n",
        "method_order = [METHODS_LEGEND[m] for m in METHODS]\n",
        "\n",
        "METHODS_STEPS = [method+\"_steps\" for method in METHODS]\n",
        "\n",
        "df = load_comp_grad_results_metrics(\n",
        "    base_dir=COMP_GRAD_DIR,\n",
        "    methods=METHODS_STEPS,\n",
        "    methods_legend=METHODS_LEGEND,\n",
        "    parse_backwardTol=True,\n",
        ")\n",
        "\n",
        "df[\"method\"] = pd.Categorical(df[\"method\"], categories=method_order, ordered=True)\n"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": 4,
      "id": "af45fabd",
      "metadata": {},
      "outputs": [],
      "source": [
        "markers = [\"o\", \"s\", \"D\", \"^\", \"v\", \"x\", \"P\", \"s\"]\n",
        "markers_dict = {m: markers[i] for i, m in enumerate(method_order)}\n",
        "plot_comp_grad_metrics_vs_iter_by_ydim(\n",
        "    df,\n",
        "    plot_path=COMP_GRAD_DIR,\n",
        "    plot_name_tag=\"grad\",\n",
        "    filter_method=\"FFOCP\",\n",
        "    filter_backwardTol=1e-5,\n",
        "    cosine_ylim=(0.5, 1.0),\n",
        "    legend_ncol=4,\n",
        ")\n",
        "\n",
        "# if this not work, try decrease lr."
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "id": "3cb8e08c",
      "metadata": {},
      "outputs": [],
      "source": []
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "id": "4128687f",
      "metadata": {},
      "outputs": [],
      "source": []
    }
  ],
  "metadata": {
    "kernelspec": {
      "display_name": "rl",
      "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": 5
}