Skip to content

Commit

Permalink
Merge pull request turing-usp#7 from turing-usp/slime-volleyball
Browse files Browse the repository at this point in the history
🐛 Corrige problemas na hora de carregar um modelo do SlimeVolleyball
  • Loading branch information
Berbardo authored Feb 10, 2022
2 parents a693a73 + e95c4f2 commit 551d01d
Showing 1 changed file with 32 additions and 29 deletions.
61 changes: 32 additions & 29 deletions Tarefa Extra - SlimeVolleyball.ipynb
Original file line number Diff line number Diff line change
@@ -1,20 +1,4 @@
{
"nbformat": 4,
"nbformat_minor": 0,
"metadata": {
"colab": {
"name": "SlimeVolleyball.ipynb",
"provenance": [],
"collapsed_sections": []
},
"kernelspec": {
"name": "python3",
"display_name": "Python 3"
},
"language_info": {
"name": "python"
}
},
"cells": [
{
"cell_type": "markdown",
Expand All @@ -29,16 +13,16 @@
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "eO3Jc2pOXLgD"
},
"outputs": [],
"source": [
"# Instala as bibliotecas necessárias\n",
"!pip install stable_baselines3\n",
"!pip install git+https://github.com/turing-usp/slimevolleygym"
],
"execution_count": null,
"outputs": []
]
},
{
"cell_type": "markdown",
Expand All @@ -51,23 +35,25 @@
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "xf0FPkw85huS"
},
"outputs": [],
"source": [
"from google.colab import drive\n",
"\n",
"# Permite acesso ao seu drive\n",
"drive.mount('/content/drive')"
],
"execution_count": null,
"outputs": []
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "ucaK_ds0XSh6"
},
"outputs": [],
"source": [
"import os\n",
"import gym\n",
Expand Down Expand Up @@ -104,8 +90,11 @@
" )\n",
"\n",
"# Carrega modelo salvo caso já exista\n",
"if os.path.exists(LOGDIR + \"/best_model\"):\n",
" model = PPO.load(LOGDIR + \"/best_model\", env=env, n_steps=4096, n_epochs=10)\n",
"if os.path.exists(LOGDIR + \"/best_model.zip\"):\n",
" model = PPO.load(LOGDIR + \"/best_model\", env=env, n_steps=4096, batch_size=32, ent_coef=0.005, n_epochs=10,\n",
" learning_rate=3e-4, clip_range=0.2, gamma=0.99, gae_lambda=0.95, verbose=2\n",
" # , policy_kwargs = model_arch # Descomentar caso tenha interesse em usar outras arquiteturas!!!\n",
" )\n",
"\n",
"# Salva o melhor modelo a cada avaliação\n",
"eval_callback = EvalCallback(env, best_model_save_path=LOGDIR, log_path=LOGDIR, eval_freq=EVAL_FREQ, n_eval_episodes=EVAL_EPISODES)\n",
Expand All @@ -116,9 +105,23 @@
"model.save(os.path.join(LOGDIR, \"final_model\"))\n",
"\n",
"env.close()"
],
"execution_count": null,
"outputs": []
]
}
]
}
],
"metadata": {
"colab": {
"collapsed_sections": [],
"name": "SlimeVolleyball.ipynb",
"provenance": []
},
"kernelspec": {
"display_name": "Python 3",
"name": "python3"
},
"language_info": {
"name": "python"
}
},
"nbformat": 4,
"nbformat_minor": 0
}

0 comments on commit 551d01d

Please sign in to comment.