Snake SL - Supervised Learning that solves the Snake game. SL was implemented by Gradient-Free-Optimizers library available for Python, neural networks was created in Keras and game was created in Pygame.
You have to installed Python 3.7.9 and other requirements which are necessary for run the program (requirements.txt).
If you want to find optimal hyperparams for neural network, you need to:
- change
OPTIMIZATION = True
- change
LOAD_WEIHTS = False
- run
main.py
When the hyperparams optimization is complete, a files will be created in the logs and weights folder.
If you want to train neural network on optimal hyperparams you need to:
- change
OPTIMIZATION = False
- change
LOAD_WEIGHTS = False
- search all
logs/scores_name.txt
files in logs folder and find the file with highest score --> e.g.logs/scores_20210517130546.txt
- change in
main.py
-->best_para = {'no_of_layers': number, 'no_of_neurons': number, 'lr': number, 'batch_size': number, 'epochs': number}
--> e.g.best_para = {'no_of_layers': 4, 'no_of_neurons': 64, 'lr': 0.001, 'batch_size': 192, 'epochs': 7}
from file with the highest score - run
main.py
When the training is complete, a file will be created in the weights folder.
If you want to test trained neural network on optimal hyperparams you need to:
- change
OPTIMIZATION = False
- change
LOAD_WEIGHTS = True
- change in
neural_network.py
-->self.network.load_weights('weights/model_name.h5')
--> e.g.self.network.load_weights('weights/model20210525141121.h5')
- run
main.py
When the training is complete, a file will be created in the results folder.
If you want to create graph you need to:
- change in
helper.py
-->with open('results/results_name.csv') as results_file:
--> e.g.with open('results/results20210525073747.csv') as results_file:
- run
helper.py