Skip to content

Commit

Permalink
implemented call to log staight line after early stopping
Browse files Browse the repository at this point in the history
  • Loading branch information
majoma7 committed Aug 17, 2024
1 parent cc7d29f commit c59d0bf
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 48 deletions.
5 changes: 2 additions & 3 deletions ddopnew/experiment_functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,6 @@ def __init__(
self.criteria = criteria
self.direction = direction

print("warmup", warmup)
print("patience", patience)

def add_result(self,
J: float, # Return (discounted rewards) of the last epoch
R: float, # Total rewards of the last epoch
Expand Down Expand Up @@ -337,6 +334,7 @@ def run_experiment( agent: BaseAgent,
stop = False

if stop:
log_info(R, J, n_epochs-epoch-1, tracking, "val")
logging.info(f"Early stopping after {epoch+1} epochs")
break

Expand Down Expand Up @@ -393,6 +391,7 @@ def run_experiment( agent: BaseAgent,
stop = False

if stop:
log_info(R, J, n_epochs-epoch-1, tracking, "val")
logging.info(f"Early stopping after {epoch+1} epochs")
break

Expand Down
38 changes: 20 additions & 18 deletions nbs/30_experiment_functions/10_experiment_functions.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
},
{
"cell_type": "code",
"execution_count": 1,
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -20,7 +20,7 @@
},
{
"cell_type": "code",
"execution_count": 2,
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -30,7 +30,7 @@
},
{
"cell_type": "code",
"execution_count": 3,
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -57,7 +57,7 @@
},
{
"cell_type": "code",
"execution_count": 4,
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
Expand Down Expand Up @@ -122,7 +122,7 @@
},
{
"cell_type": "code",
"execution_count": 5,
"execution_count": null,
"metadata": {},
"outputs": [
{
Expand Down Expand Up @@ -174,7 +174,7 @@
"| direction | str | max | Whether reward shall be maximized or minimized |"
]
},
"execution_count": 5,
"execution_count": null,
"metadata": {},
"output_type": "execute_result"
}
Expand All @@ -185,7 +185,7 @@
},
{
"cell_type": "code",
"execution_count": 6,
"execution_count": null,
"metadata": {},
"outputs": [
{
Expand Down Expand Up @@ -225,7 +225,7 @@
"| **Returns** | **bool** | |"
]
},
"execution_count": 6,
"execution_count": null,
"metadata": {},
"output_type": "execute_result"
}
Expand All @@ -245,7 +245,7 @@
},
{
"cell_type": "code",
"execution_count": 7,
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
Expand Down Expand Up @@ -341,7 +341,7 @@
},
{
"cell_type": "code",
"execution_count": 8,
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
Expand Down Expand Up @@ -521,6 +521,7 @@
" stop = False\n",
"\n",
" if stop:\n",
" log_info(R, J, n_epochs-epoch-1, tracking, \"val\")\n",
" logging.info(f\"Early stopping after {epoch+1} epochs\")\n",
" break\n",
" \n",
Expand Down Expand Up @@ -577,6 +578,7 @@
" stop = False\n",
"\n",
" if stop:\n",
" log_info(R, J, n_epochs-epoch-1, tracking, \"val\")\n",
" logging.info(f\"Early stopping after {epoch+1} epochs\")\n",
" break\n",
" \n",
Expand All @@ -598,7 +600,7 @@
},
{
"cell_type": "code",
"execution_count": 9,
"execution_count": null,
"metadata": {},
"outputs": [
{
Expand Down Expand Up @@ -672,7 +674,7 @@
"| eval_step_info | bool | False | |"
]
},
"execution_count": 9,
"execution_count": null,
"metadata": {},
"output_type": "execute_result"
}
Expand Down Expand Up @@ -713,7 +715,7 @@
},
{
"cell_type": "code",
"execution_count": 10,
"execution_count": null,
"metadata": {},
"outputs": [
{
Expand Down Expand Up @@ -761,7 +763,7 @@
"| eval_step_info | bool | False | |"
]
},
"execution_count": 10,
"execution_count": null,
"metadata": {},
"output_type": "execute_result"
}
Expand All @@ -772,7 +774,7 @@
},
{
"cell_type": "code",
"execution_count": 11,
"execution_count": null,
"metadata": {},
"outputs": [
{
Expand Down Expand Up @@ -820,7 +822,7 @@
"| eval_step_info | bool | False | Print step info during evaluation |"
]
},
"execution_count": 11,
"execution_count": null,
"metadata": {},
"output_type": "execute_result"
}
Expand All @@ -838,7 +840,7 @@
},
{
"cell_type": "code",
"execution_count": 12,
"execution_count": null,
"metadata": {},
"outputs": [
{
Expand Down Expand Up @@ -882,7 +884,7 @@
},
{
"cell_type": "code",
"execution_count": 13,
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
Expand Down
42 changes: 15 additions & 27 deletions nbs/30_experiment_functions/20_meta_experiment_functions.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
},
{
"cell_type": "code",
"execution_count": 16,
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -20,7 +20,7 @@
},
{
"cell_type": "code",
"execution_count": 17,
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -30,7 +30,7 @@
},
{
"cell_type": "code",
"execution_count": 18,
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
Expand Down Expand Up @@ -73,7 +73,7 @@
},
{
"cell_type": "code",
"execution_count": 19,
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
Expand Down Expand Up @@ -110,7 +110,7 @@
},
{
"cell_type": "code",
"execution_count": 20,
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -127,7 +127,7 @@
},
{
"cell_type": "code",
"execution_count": 21,
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -151,7 +151,7 @@
},
{
"cell_type": "code",
"execution_count": 22,
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
Expand Down Expand Up @@ -202,7 +202,7 @@
},
{
"cell_type": "code",
"execution_count": 23,
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
Expand Down Expand Up @@ -237,7 +237,7 @@
},
{
"cell_type": "code",
"execution_count": 24,
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -259,7 +259,7 @@
},
{
"cell_type": "code",
"execution_count": 25,
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -284,7 +284,7 @@
},
{
"cell_type": "code",
"execution_count": 26,
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
Expand Down Expand Up @@ -312,7 +312,7 @@
},
{
"cell_type": "code",
"execution_count": 27,
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
Expand Down Expand Up @@ -356,7 +356,7 @@
},
{
"cell_type": "code",
"execution_count": 28,
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
Expand Down Expand Up @@ -389,7 +389,7 @@
},
{
"cell_type": "code",
"execution_count": 29,
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -406,7 +406,7 @@
},
{
"cell_type": "code",
"execution_count": 30,
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
Expand Down Expand Up @@ -441,18 +441,6 @@
"display_name": "python3",
"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.11.0"
}
},
"nbformat": 4,
Expand Down

0 comments on commit c59d0bf

Please sign in to comment.