Code Monkey home page Code Monkey logo

snake-sl's Introduction

Snake-SL

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).

Example

Hyperparams optimization

If you want to find optimal hyperparams for neural network, you need to:

  1. change OPTIMIZATION = True
  2. change LOAD_WEIHTS = False
  3. run main.py

Example

Train neural network on optimal hyperparams

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:

  1. change OPTIMIZATION = False
  2. change LOAD_WEIGHTS = False
  3. search all logs/scores_name.txt files in logs folder and find the file with highest score --> e.g. logs/scores_20210517130546.txt
  4. 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
  5. run main.py

Test trained neural network on optimal hyperparams

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:

  1. change OPTIMIZATION = False
  2. change LOAD_WEIGHTS = True
  3. change in neural_network.py --> self.network.load_weights('weights/model_name.h5') --> e.g. self.network.load_weights('weights/model20210525141121.h5')
  4. run main.py

Create graph

When the training is complete, a file will be created in the results folder.

If you want to create graph you need to:

  1. change in helper.py --> with open('results/results_name.csv') as results_file: --> e.g. with open('results/results20210525073747.csv') as results_file:
  2. run helper.py

snake-sl's People

Contributors

petomuro avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.