Skip to content

Latest commit

 

History

History
51 lines (40 loc) · 2.37 KB

README.md

File metadata and controls

51 lines (40 loc) · 2.37 KB

Text to Image additions/subtractions solver using Recurrent Neural Networks

This repository contains the solution to the task 1.4 of the third assignment of the course Introduction to Deep Learning (Leiden University).
The goal is to predict the solution to addition/subtraction between two 3-digits (or less) numbers. The first number has to be positive. What makes this task not trivial is that the model has to generate the solution as a sequence of 4 images, each representing a digit, a - sign, or an empty space.

Requirements

  • Numpy - pip install numpy
  • TensorFlow - pip install -U tensorflow
  • Matplotlib - pip install -U matplotlib
  • Scikit-learn - pip install -U scikit-learn

Training

 python --train PATH_1 --data PATH_2 --train_size 0.7 --pretrained PATH_3 --summary

Remove --pretrained for training the model from scratch.
PATH_1: path where to store the weights after the training
PATH_2: path to dataset PATH_3: path to pretrained weights

Note:

The data that I used was composed of different MNIST images stacked together, where + (optional, an empty image is sufficient) and - symbols were (partly) randomly generated using OpenCV. I will provide the data and/or the script to generate it in the future.

Evaluation

Evaluate a single expression defined in --eval. The expression must have the form ddd?ddd, d=digit or whitespace and ?=+ or - (e.g. " 27+  5").

 python --eval "640-200" --pretrained PATH_1 --eval_out PATH_2

PATH_1: path to pretrained weights
PATH_2: path where to save the output images

Examples

2 - 78 =

555 + 500 =

623 + 271 =

640 - 200 =

950 - 20 =

999 + 700 =