/deep_learning_code_comparison

Deep learning frameworks from coders perspective

Primary LanguageJupyter Notebook

Deep learning frameworks from coders perspective

This repository includes sample python codes and notebooks for some common usecases for various deep learning frameworks. Notebooks were done from the viewpoint of incrementally solving a specific problems. E.g. after defining a model there is a test that the code works by running on predicition instead of just trusting that the code is right.

Mnist cnn image classification example

  • Load mnist data
    • Show some samples
  • Define simple cnn model
    • Test the code ... Train the model and print progress information ... Test the accuracy of the model
  • Persist the work for future use
    • Save the model ... Load the model ... Predict one image with the loaded model

Different frameworks

Openai gym cartople reinforcement (qdn) example

  • Small network that can learn to solve CartPole environment with reinforcement learning
  • Code is supposed to be clear and generalizable. Not the most optimized reinforcement learning for this problem.

Different frameworks

Cats and dogs, finetuning a pretrained model

  • Load data and set up basic data transformations
  • Use pretrained convolutional layers from vgg16 and finetune simple top on that.
  • Show some sample predictions

Different frameworks

What to pay attention to while looking through the code/notebooks

Keras feels the most beginner coder friendly. It's nice that when you are defining the model you don't have to calculate the layer's input sizes manually. Fitting prints nice progress to the notebook. Saving and loading a model is straight forward.

Pytorch feels very pythonic. Everything requires a bit more code but it's simple to write and easy to debug. Most flexible option as the network was dynamic.

TensorFlow was very hard to code and debug. Even though TF seems to have most candy on the top, for example serving models in production environments or tensorboard visualization, the basic development was unintuitive. Separation of the graph definition and the graph usage complicated the development especially in notebook environment. It was too easy to forget to reset or initialize the graph and get some weird errors.