Update Unit 2 notebook

This commit is contained in:
Thomas Simonini
2022-12-12 14:07:04 +01:00
committed by GitHub
parent 751a562f3a
commit 1dc62782be

View File

@@ -71,7 +71,7 @@
{
"cell_type": "markdown",
"source": [
"## This notebook is from Deep Reinforcement Learning Course\n",
"## This notebook is from the Deep Reinforcement Learning Course\n",
"<img src=\"https://huggingface.co/datasets/huggingface-deep-rl-course/course-images/resolve/main/en/notebooks/deep-rl-course-illustration.jpg\" alt=\"Deep RL Course illustration\"/>"
],
"metadata": {
@@ -190,7 +190,7 @@
},
"outputs": [],
"source": [
"!pip install -r https://github.com/huggingface/deep-rl-class/tree/main/notebooks/unit2/requirements-unit2.txt"
"!pip install -r pip install -r https://raw.githubusercontent.com/huggingface/deep-rl-class/main/notebooks/unit2/requirements-unit2.txt"
]
},
{
@@ -996,7 +996,7 @@
},
"outputs": [],
"source": [
"from huggingface_hub import HfApi, HfFolder, Repository, snapshot_download\n",
"from huggingface_hub import HfApi, snapshot_download\n",
"from huggingface_hub.repocard import metadata_eval_result, metadata_save\n",
"\n",
"from pathlib import Path\n",
@@ -1074,8 +1074,6 @@
" if env.spec.kwargs.get(\"is_slippery\", \"\") == False:\n",
" model[\"slippery\"] = False\n",
"\n",
" print(model)\n",
"\n",
" # Pickle the model\n",
" with open((repo_local_path) / \"q-learning.pkl\", \"wb\") as f:\n",
" pickle.dump(model, f)\n",
@@ -1092,7 +1090,8 @@
" \"eval_datetime\": datetime.datetime.now().isoformat()\n",
" }\n",
"\n",
" # Write a JSON file\n",
" # Write a JSON file called \"results.json\" that will contain the\n",
" # evaluation results\n",
" with open(repo_local_path / \"results.json\", \"w\") as outfile:\n",
" json.dump(evaluate_data, outfile)\n",
"\n",
@@ -1139,7 +1138,6 @@
"\n",
" evaluate_agent(env, model[\"max_steps\"], model[\"n_eval_episodes\"], model[\"qtable\"], model[\"eval_seed\"])\n",
" \n",
"\n",
" readme_path = repo_local_path / \"README.md\"\n",
" readme = \"\"\n",
" print(readme_path.exists())\n",
@@ -1148,7 +1146,6 @@
" readme = f.read()\n",
" else:\n",
" readme = model_card\n",
" print(readme)\n",
"\n",
" with readme_path.open(\"w\", encoding=\"utf-8\") as f:\n",
" f.write(readme)\n",