/Master-Thesis

Implementation of the concept presented in my Master's-Thesis

Primary LanguagePython

Master's Thesis

Code style: black

Requirements

  • Python 3.8
  • Poetry 1.1
  • graphviz (optional)
  • manim (optional)

Setup (tested on MacOS and Windows)

  1. Download & install the latest python 3.8 release from here

  2. Download and install poetry as explained here

  3. Optional: Install graphviz

    Mac:
    brew install graphviz
    
    Windows:
    choco install graphviz
    

4.1. Optional: Install manim dependencies as described here

4.2. Optional: Run poetry add manimce==0.1 to add manim to poetry

  1. Run poetry install in the root of the repository to create a virtual environment and install the required dependencies

  2. Run one of the run scripts ...

    6.1. ... using the command line

    poetry shell
    
    poetry run python rl/main_dataset.py
    poetry run python rl/main.py
    poetry run python supervised/main.py
    

    6.2. ... through an IDE:

    • Select the poetry venv as interpreter & run one of the run scripts

Graphviz

If Graphviz is installed, the architecture images can be generated by using the save_model_architecture_images() method that is implemented in Network and its inheriting classes (e.g. NetworkRL and NetworkSupervised)

Manim

Manim is required to use the RLScene class script in animation/network_scene. If it is set up, a video file can be generated by running

manim animation/network_scene.py RLScene -p -qp

More information about manim can be found here

RLScene

  • animates the training process of the Reinforcement Learner
  • not designed to be too generic
    • might need adjustments when changing parameters

Black

Black is used to ensure a consistent code style. Additionally, a pre-commit hook is configured and can be activated by running pre-commit install

If it is activated, the code is analyzed during a commit. If adjustments are necessary, the following happens:

  • the commit fails
  • the code gets automatically adjusted according to the Black style guide

The changes then need to be re-added and committed again.

Troubleshooting

This section lists problems encountered during the work and the required steps to resolve them

SSL Certificate issue

Occurred on macOS. Can be fixed when running the following command to install necessary certificates:

/Applications/Python 3.8/Install Certificates.command

Good to know

  1. All run scripts are designed to be invoked from the root directory! (e.g. running main_dataset.py from within the rl folder does not work)

  2. The main scripts in the experiment branches were invoked via PyCharm and likely fail to run when invoked from the command line because the repository root folder is not in the pythonpath. This can be addressed by adding the following lines on top of the run scripts.

    import sys
    import os
    sys.path.insert(0, os.getcwd())

    Those lines are already included for all run scripts on the master branch.