{ "cells": [ { "cell_type": "code", "execution_count": 3, "id": "220eae6e", "metadata": {}, "outputs": [ { "data": { "application/vnd.plotly.v1+json": { "config": { "plotlyServerURL": "https://plot.ly" }, "data": [ { "line": { "color": "blue", "width": 2 }, "mode": "lines", "name": "Loss", "type": "scatter", "x": [ 0.02, 0.04, 0.07, 0.09, 0.11, 0.13, 0.15, 0.17, 0.2, 0.22, 0.24, 0.26, 0.28, 0.31, 0.33, 0.35000000000000003, 0.37, 0.39, 0.42, 0.44, 0.46, 0.48, 0.5, 0.52, 0.55, 0.5700000000000001, 0.59, 0.61, 0.63, 0.66, 0.68, 0.7000000000000001, 0.72, 0.74, 0.77, 0.79, 0.81, 0.8300000000000001, 0.85, 0.87, 0.9, 0.92, 0.9400000000000001, 0.96, 0.98, 1.01, 1.03, 1.05, 1.07, 1.09, 1.12, 1.1400000000000001, 1.16, 1.18, 1.2, 1.22, 1.25, 1.27, 1.29, 1.31, 1.33, 1.3599999999999999, 1.38, 1.4, 1.42, 1.44, 1.47, 1.49, 1.51, 1.53, 1.55, 1.57, 1.6, 1.62, 1.6400000000000001, 1.6600000000000001, 1.6800000000000002, 1.71, 1.73, 1.75, 1.77, 1.79, 1.82, 1.8399999999999999, 1.8599999999999999, 1.88, 1.9, 1.92, 1.9500000000000002, 1.97, 1.99, 2.01, 2.03, 2.06, 2.08, 2.1, 2.12, 2.14, 2.16, 2.19, 2.21, 2.23, 2.25, 2.27, 2.3, 2.32, 2.34, 2.36, 2.38, 2.41, 2.43, 2.45, 2.47, 2.49, 2.51, 2.54, 2.56, 2.58, 2.6, 2.62, 2.65, 2.67, 2.69, 2.71, 2.73, 2.76, 2.7800000000000002, 2.8, 2.8200000000000003, 2.84, 2.86, 2.89, 2.91, 2.93, 2.95, 2.9699999999999998, 3, null ], "y": [ 1.8747, 1.7998, 1.7788, 1.7681, 1.7504, 1.7426, 1.7515, 1.7297, 1.7266, 1.716, 1.7168, 1.7136, 1.7018, 1.6961, 1.7138, 1.7039, 1.698, 1.6897, 1.6895, 1.6914, 1.6772, 1.6738, 1.6739000000000002, 1.6644999999999999, 1.6601, 1.6522999999999999, 1.6626, 1.6574, 1.6748, 1.6680000000000001, 1.6560000000000001, 1.6487, 1.6537000000000002, 1.655, 1.6492, 1.6477, 1.642, 1.6285, 1.6415000000000002, 1.6349, 1.6272, 1.6268, 1.6244, 1.6253000000000002, 1.6337000000000002, 1.6131, 1.6085, 1.6141, 1.6097000000000001, 1.6068, 1.5991, 1.6001, 1.5873, 1.5979, 1.5989, 1.5973000000000002, 1.5945, 1.581, 1.5826, 1.5939999999999999, 1.5812, 1.5779, 1.5807, 1.5815000000000001, 1.5877, 1.5694, 1.5807, 1.5794000000000001, 1.5798, 1.5702, 1.5756999999999999, 1.5699, 1.5691000000000002, 1.5566, 1.562, 1.5541, 1.5554000000000001, 1.5596999999999999, 1.5508000000000002, 1.5551, 1.5636999999999999, 1.5442, 1.5521, 1.5468000000000002, 1.5492, 1.5510000000000002, 1.5483, 1.5499, 1.5272999999999999, 1.5441, 1.5401, 1.5262, 1.5231, 1.5282, 1.5209000000000001, 1.5224, 1.5072, 1.5152999999999999, 1.5189, 1.5185, 1.5072999999999999, 1.522, 1.5158, 1.5102, 1.5093, 1.5101, 1.5062, 1.5039, 1.494, 1.5095, 1.5021, 1.5046, 1.4966, 1.4875, 1.5078, 1.4892, 1.4984, 1.4963, 1.4895, 1.5005000000000002, 1.4999, 1.4832, 1.495, 1.499, 1.4831, 1.4854, 1.4918, 1.4914, 1.4836, 1.4828999999999999, 1.4824, 1.4856, 1.487, 1.4791, 1.4779, 1.4794, 1.476, null ] } ], "layout": { "template": { "data": { "bar": [ { "error_x": { "color": "#2a3f5f" }, "error_y": { "color": "#2a3f5f" }, "marker": { "line": { "color": "white", "width": 0.5 }, "pattern": { "fillmode": "overlay", "size": 10, "solidity": 0.2 } }, "type": "bar" } ], "barpolar": [ { "marker": { "line": { "color": "white", "width": 0.5 }, "pattern": { "fillmode": "overlay", "size": 10, "solidity": 0.2 } }, "type": "barpolar" } ], "carpet": [ { "aaxis": { "endlinecolor": "#2a3f5f", "gridcolor": "#C8D4E3", "linecolor": "#C8D4E3", "minorgridcolor": "#C8D4E3", "startlinecolor": "#2a3f5f" }, "baxis": { "endlinecolor": "#2a3f5f", "gridcolor": "#C8D4E3", "linecolor": "#C8D4E3", "minorgridcolor": "#C8D4E3", "startlinecolor": "#2a3f5f" }, "type": "carpet" } ], "choropleth": [ { "colorbar": { "outlinewidth": 0, "ticks": "" }, "type": "choropleth" } ], "contour": [ { "colorbar": { "outlinewidth": 0, "ticks": "" }, "colorscale": [ [ 0, "#0d0887" ], [ 0.1111111111111111, "#46039f" ], [ 0.2222222222222222, "#7201a8" ], [ 0.3333333333333333, "#9c179e" ], [ 0.4444444444444444, "#bd3786" ], [ 0.5555555555555556, "#d8576b" ], [ 0.6666666666666666, "#ed7953" ], [ 0.7777777777777778, "#fb9f3a" ], [ 0.8888888888888888, "#fdca26" ], [ 1, "#f0f921" ] ], "type": "contour" } ], "contourcarpet": [ { "colorbar": { "outlinewidth": 0, "ticks": "" }, "type": "contourcarpet" } ], "heatmap": [ { "colorbar": { "outlinewidth": 0, "ticks": "" }, "colorscale": [ [ 0, "#0d0887" ], [ 0.1111111111111111, "#46039f" ], [ 0.2222222222222222, "#7201a8" ], [ 0.3333333333333333, "#9c179e" ], [ 0.4444444444444444, "#bd3786" ], [ 0.5555555555555556, "#d8576b" ], [ 0.6666666666666666, "#ed7953" ], [ 0.7777777777777778, "#fb9f3a" ], [ 0.8888888888888888, "#fdca26" ], [ 1, "#f0f921" ] ], "type": "heatmap" } ], "heatmapgl": [ { "colorbar": { "outlinewidth": 0, "ticks": "" }, "colorscale": [ [ 0, "#0d0887" ], [ 0.1111111111111111, "#46039f" ], [ 0.2222222222222222, "#7201a8" ], [ 0.3333333333333333, "#9c179e" ], [ 0.4444444444444444, "#bd3786" ], [ 0.5555555555555556, "#d8576b" ], [ 0.6666666666666666, "#ed7953" ], [ 0.7777777777777778, "#fb9f3a" ], [ 0.8888888888888888, "#fdca26" ], [ 1, "#f0f921" ] ], "type": "heatmapgl" } ], "histogram": [ { "marker": { "pattern": { "fillmode": "overlay", "size": 10, "solidity": 0.2 } }, "type": "histogram" } ], "histogram2d": [ { "colorbar": { "outlinewidth": 0, "ticks": "" }, "colorscale": [ [ 0, "#0d0887" ], [ 0.1111111111111111, "#46039f" ], [ 0.2222222222222222, "#7201a8" ], [ 0.3333333333333333, "#9c179e" ], [ 0.4444444444444444, "#bd3786" ], [ 0.5555555555555556, "#d8576b" ], [ 0.6666666666666666, "#ed7953" ], [ 0.7777777777777778, "#fb9f3a" ], [ 0.8888888888888888, "#fdca26" ], [ 1, "#f0f921" ] ], "type": "histogram2d" } ], "histogram2dcontour": [ { "colorbar": { "outlinewidth": 0, "ticks": "" }, "colorscale": [ [ 0, "#0d0887" ], [ 0.1111111111111111, "#46039f" ], [ 0.2222222222222222, "#7201a8" ], [ 0.3333333333333333, "#9c179e" ], [ 0.4444444444444444, "#bd3786" ], [ 0.5555555555555556, "#d8576b" ], [ 0.6666666666666666, "#ed7953" ], [ 0.7777777777777778, "#fb9f3a" ], [ 0.8888888888888888, "#fdca26" ], [ 1, "#f0f921" ] ], "type": "histogram2dcontour" } ], "mesh3d": [ { "colorbar": { "outlinewidth": 0, "ticks": "" }, "type": "mesh3d" } ], "parcoords": [ { "line": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "type": "parcoords" } ], "pie": [ { "automargin": true, "type": "pie" } ], "scatter": [ { "fillpattern": { "fillmode": "overlay", "size": 10, "solidity": 0.2 }, "type": "scatter" } ], "scatter3d": [ { "line": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "marker": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "type": "scatter3d" } ], "scattercarpet": [ { "marker": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "type": "scattercarpet" } ], "scattergeo": [ { "marker": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "type": "scattergeo" } ], "scattergl": [ { "marker": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "type": "scattergl" } ], "scattermapbox": [ { "marker": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "type": "scattermapbox" } ], "scatterpolar": [ { "marker": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "type": "scatterpolar" } ], "scatterpolargl": [ { "marker": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "type": "scatterpolargl" } ], "scatterternary": [ { "marker": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "type": "scatterternary" } ], "surface": [ { "colorbar": { "outlinewidth": 0, "ticks": "" }, "colorscale": [ [ 0, "#0d0887" ], [ 0.1111111111111111, "#46039f" ], [ 0.2222222222222222, "#7201a8" ], [ 0.3333333333333333, "#9c179e" ], [ 0.4444444444444444, "#bd3786" ], [ 0.5555555555555556, "#d8576b" ], [ 0.6666666666666666, "#ed7953" ], [ 0.7777777777777778, "#fb9f3a" ], [ 0.8888888888888888, "#fdca26" ], [ 1, "#f0f921" ] ], "type": "surface" } ], "table": [ { "cells": { "fill": { "color": "#EBF0F8" }, "line": { "color": "white" } }, "header": { "fill": { "color": "#C8D4E3" }, "line": { "color": "white" } }, "type": "table" } ] }, "layout": { "annotationdefaults": { "arrowcolor": "#2a3f5f", "arrowhead": 0, "arrowwidth": 1 }, "autotypenumbers": "strict", "coloraxis": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "colorscale": { "diverging": [ [ 0, "#8e0152" ], [ 0.1, "#c51b7d" ], [ 0.2, "#de77ae" ], [ 0.3, "#f1b6da" ], [ 0.4, "#fde0ef" ], [ 0.5, "#f7f7f7" ], [ 0.6, "#e6f5d0" ], [ 0.7, "#b8e186" ], [ 0.8, "#7fbc41" ], [ 0.9, "#4d9221" ], [ 1, "#276419" ] ], "sequential": [ [ 0, "#0d0887" ], [ 0.1111111111111111, "#46039f" ], [ 0.2222222222222222, "#7201a8" ], [ 0.3333333333333333, "#9c179e" ], [ 0.4444444444444444, "#bd3786" ], [ 0.5555555555555556, "#d8576b" ], [ 0.6666666666666666, "#ed7953" ], [ 0.7777777777777778, "#fb9f3a" ], [ 0.8888888888888888, "#fdca26" ], [ 1, "#f0f921" ] ], "sequentialminus": [ [ 0, "#0d0887" ], [ 0.1111111111111111, "#46039f" ], [ 0.2222222222222222, "#7201a8" ], [ 0.3333333333333333, "#9c179e" ], [ 0.4444444444444444, "#bd3786" ], [ 0.5555555555555556, "#d8576b" ], [ 0.6666666666666666, "#ed7953" ], [ 0.7777777777777778, "#fb9f3a" ], [ 0.8888888888888888, "#fdca26" ], [ 1, "#f0f921" ] ] }, "colorway": [ "#636efa", "#EF553B", "#00cc96", "#ab63fa", "#FFA15A", "#19d3f3", "#FF6692", "#B6E880", "#FF97FF", "#FECB52" ], "font": { "color": "#2a3f5f" }, "geo": { "bgcolor": "white", "lakecolor": "white", "landcolor": "white", "showlakes": true, "showland": true, "subunitcolor": "#C8D4E3" }, "hoverlabel": { "align": "left" }, "hovermode": "closest", "mapbox": { "style": "light" }, "paper_bgcolor": "white", "plot_bgcolor": "white", "polar": { "angularaxis": { "gridcolor": "#EBF0F8", "linecolor": "#EBF0F8", "ticks": "" }, "bgcolor": "white", "radialaxis": { "gridcolor": "#EBF0F8", "linecolor": "#EBF0F8", "ticks": "" } }, "scene": { "xaxis": { "backgroundcolor": "white", "gridcolor": "#DFE8F3", "gridwidth": 2, "linecolor": "#EBF0F8", "showbackground": true, "ticks": "", "zerolinecolor": "#EBF0F8" }, "yaxis": { "backgroundcolor": "white", "gridcolor": "#DFE8F3", "gridwidth": 2, "linecolor": "#EBF0F8", "showbackground": true, "ticks": "", "zerolinecolor": "#EBF0F8" }, "zaxis": { "backgroundcolor": "white", "gridcolor": "#DFE8F3", "gridwidth": 2, "linecolor": "#EBF0F8", "showbackground": true, "ticks": "", "zerolinecolor": "#EBF0F8" } }, "shapedefaults": { "line": { "color": "#2a3f5f" } }, "ternary": { "aaxis": { "gridcolor": "#DFE8F3", "linecolor": "#A2B1C6", "ticks": "" }, "baxis": { "gridcolor": "#DFE8F3", "linecolor": "#A2B1C6", "ticks": "" }, "bgcolor": "white", "caxis": { "gridcolor": "#DFE8F3", "linecolor": "#A2B1C6", "ticks": "" } }, "title": { "x": 0.05 }, "xaxis": { "automargin": true, "gridcolor": "#EBF0F8", "linecolor": "#EBF0F8", "ticks": "", "title": { "standoff": 15 }, "zerolinecolor": "#EBF0F8", "zerolinewidth": 2 }, "yaxis": { "automargin": true, "gridcolor": "#EBF0F8", "linecolor": "#EBF0F8", "ticks": "", "title": { "standoff": 15 }, "zerolinecolor": "#EBF0F8", "zerolinewidth": 2 } } }, "title": { "text": "Loss Curve for BERT-base (wikitext)" }, "xaxis": { "title": { "text": "Epochs" } }, "yaxis": { "title": { "text": "Loss" } } } } }, "metadata": {}, "output_type": "display_data" } ], "source": [ "import pandas as pd\n", "import plotly.graph_objs as go\n", "\n", "df = pd.read_json(\"trainer_state.json\")\n", "\n", "df['loss_curve'] = df.log_history[:-1].apply(lambda d: d[\"loss\"])\n", "df['epoch'] = df.log_history[:-1].apply(lambda d: d[\"epoch\"])\n", "\n", "df = df[['epoch', 'loss_curve']]\n", "\n", "trace = go.Scatter(x=df['epoch'], y=df['loss_curve'], \n", " mode='lines', name='Loss', line=dict(color='blue', width=2))\n", "\n", "layout = go.Layout(title=f'Loss Curve for BERT-base (wikitext)', \n", " xaxis=dict(title='Epochs'), \n", " yaxis=dict(title='Loss'), \n", " template='plotly_white')\n", "\n", "fig = go.Figure(data=[trace], layout=layout)\n", "fig.show()" ] } ], "metadata": { "kernelspec": { "display_name": "Python 3 (ipykernel)", "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.9.13" } }, "nbformat": 4, "nbformat_minor": 5 }