Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Modify evaluation score processing #4

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 14 additions & 8 deletions DQN.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -1112,21 +1112,27 @@
" eval_rewards.append(episode_reward_sum)\n",
" gif = False # Save only the first game of the evaluation as a gif\n",
" \n",
" print(\"Evaluation score:\\n\", np.mean(eval_rewards)) \n",
" try:\n",
" generate_gif(frame_number, frames_for_gif, eval_rewards[0], PATH)\n",
" except IndexError:\n",
" print(\"No evaluation game finished\")\n",
" if eval_rewards:\n",
" eval_score = np.mean(eval_rewards)\n",
" first_episode_reward_sum = eval_rewards[0]\n",
" # When the first game of the evaluation is not finished\n",
" # (this would happen if the agent got stuck in a loop)\n",
" else:\n",
" eval_score = episode_reward_sum\n",
" first_episode_reward_sum = episode_reward_sum\n",
"\n",
" print(\"Evaluation score:\\n\", eval_score)\n",
" generate_gif(frame_number, frames_for_gif, first_episode_reward_sum, PATH)\n",
" \n",
" #Save the network parameters\n",
" # Save the network parameters\n",
" saver.save(sess, PATH+'/my_model', global_step=frame_number)\n",
" frames_for_gif = []\n",
" \n",
" # Show the evaluation score in tensorboard\n",
" summ = sess.run(EVAL_SCORE_SUMMARY, feed_dict={EVAL_SCORE_PH:np.mean(eval_rewards)})\n",
" summ = sess.run(EVAL_SCORE_SUMMARY, feed_dict={EVAL_SCORE_PH:eval_score})\n",
" SUMM_WRITER.add_summary(summ, frame_number)\n",
" with open('rewardsEval.dat', 'a') as eval_reward_file:\n",
" print(frame_number, np.mean(eval_rewards), file=eval_reward_file)"
" print(frame_number, eval_score, file=eval_reward_file)"
]
},
{
Expand Down