chuyangliu / snake

Artificial intelligence for the Snake game.
Apache License 2.0
1.65k stars 481 forks source link

After DQN training, how to use trained model? #34

Closed zinwalin closed 4 years ago

zinwalin commented 4 years ago

image

chuyangliu commented 4 years ago

self._FREQ_SAVE controls the frequency to save model parameters during training. Here the value is 20000, which means that model parameters will be saved every 20000 learning steps.

Saved model parameters are represented by three files under directory logs: solver-net-<steps>.data-00000-of-00001, solver-net-<steps>.index, and solver-var-<steps>.json. To use a trained model, modify self._RESTORE_STEP to the steps you want to use.

For example, if you want to use the model trained with 100000 learning steps. Ensure the three files solver-net-100000.data-00000-of-00001, solver-net-100000.index, and solver-var-100000.json are placed under directory logs. Then modify self._RESTORE_STEP to 100000. Now run the program with python3 run.py -s dqn and you are good to go!

zinwalin commented 4 years ago

to improve score, how to tweak parameters?

chuyangliu commented 4 years ago

You can tune parameters in this code region to improve score. I highly recommend going through the last four papers of the references section to understand how these parameters affect the score.